in ptp_mtpgetobjectreferences handle the case where no DATA is

returned at all.


git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@10973 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
Marcus Meissner
2008-03-01 21:37:31 +00:00
parent 9136ee350a
commit de43df6ec2
2 changed files with 19 additions and 2 deletions

View File

@@ -1,3 +1,10 @@
2008-03-01 Marcus Meissner <marcus@jet.franken.de>
* ptp.c: MTP GetObjectReferences on Sansa MTP device
can skip the dataphase, but return OK as response.
Handle this strange case here.
2008-02-22 Marcus Meissner <marcus@jet.franken.de>
* library.c, ptp.h:

View File

@@ -2797,13 +2797,23 @@ ptp_mtp_getobjectreferences (PTPParams* params, uint32_t handle, uint32_t** ohAr
PTPContainer ptp;
uint16_t ret;
unsigned char* dpv=NULL;
unsigned int dpvlen = 0;
PTP_CNT_INIT(ptp);
ptp.Code=PTP_OC_MTP_GetObjectReferences;
ptp.Param1=handle;
ptp.Nparam=1;
ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &dpv, NULL);
if (ret == PTP_RC_OK) *arraylen = ptp_unpack_uint32_t_array(params, dpv, 0, ohArray);
ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &dpv, &dpvlen);
if (ret == PTP_RC_OK) {
/* Sandisk Sansa skips the DATA phase, but returns OK as response.
* this will gives us a NULL here. Handle it. -Marcus */
if ((dpv == NULL) || (dpvlen == 0)) {
*arraylen = 0;
*ohArray = NULL;
} else {
*arraylen = ptp_unpack_uint32_t_array(params, dpv, 0, ohArray);
}
}
free(dpv);
return ret;
}