free(majorstr);
free(minorstr);
extension = malloc(sizeof(LIBMTP_device_extension_t));
- extension->name = name;
- extension->major = major;
- extension->minor = minor;
- extension->next = NULL;
+ if (extension != NULL) {
+ extension->name = name;
+ extension->major = major;
+ extension->minor = minor;
+ extension->next = NULL;
+ }
if (mtpdevice->extensions == NULL) {
mtpdevice->extensions = extension;
} else {
return;
}
newerror = (LIBMTP_error_t *) malloc(sizeof(LIBMTP_error_t));
- newerror->errornumber = errornumber;
- newerror->error_text = strdup(error_text);
- newerror->next = NULL;
+ if (newerror != NULL) {
+ newerror->errornumber = errornumber;
+ newerror->error_text = strdup(error_text);
+ newerror->next = NULL;
+ }
if (device->errorstack == NULL) {
device->errorstack = newerror;
} else {
}
lasthandle = 0xffffffff;
params->objects = calloc (cnt, sizeof(PTPObject));
+ if (params->objects == NULL) {
+ free(props);
+ return -1;
+ }
+
prop = props;
i = -1;
for (j=0;j<nrofprops;j++) {
// Extract the actual array.
// printf("Array of %d elements\n", propval.a.count);
tmp = malloc((propval.a.count + 1)*sizeof(uint16_t));
+ if (tmp == NULL) {
+ free(propval.a.v);
+ return -1;
+ }
+
for (i = 0; i < propval.a.count; i++) {
tmp[i] = propval.a.v[i].u16;
// printf("%04x ", tmp[i]);
// This is more memory than needed if there are unknown types, but what the heck.
localtypes = (uint16_t *) malloc(params->deviceinfo.ImageFormats_len * sizeof(uint16_t));
+ if (localtypes == NULL)
+ return -1;
+
localtypelen = 0;
for (i=0;i<params->deviceinfo.ImageFormats_len;i++) {
if (FLAG_OGG_IS_UNKNOWN(ptp_usb)) {
localtypes = (uint16_t *) realloc(localtypes,
(params->deviceinfo.ImageFormats_len+1) * sizeof(uint16_t));
+ if (localtypes == NULL)
+ return -1;
+
localtypes[localtypelen] = LIBMTP_FILETYPE_OGG;
localtypelen++;
}
if (FLAG_FLAC_IS_UNKNOWN(ptp_usb)) {
localtypes = (uint16_t *) realloc(localtypes,
(params->deviceinfo.ImageFormats_len+1) * sizeof(uint16_t));
+ if (localtypes == NULL)
+ return -1;
+
localtypes[localtypelen] = LIBMTP_FILETYPE_FLAC;
localtypelen++;
}
storage = (LIBMTP_devicestorage_t *)
malloc(sizeof(LIBMTP_devicestorage_t));
+ if (storage == NULL)
+ return -1;
storage->prev = storageprev;
if (storageprev != NULL)
storageprev->next = storage;
storage = (LIBMTP_devicestorage_t *)
malloc(sizeof(LIBMTP_devicestorage_t));
+ if (storage == NULL)
+ return -1;
storage->prev = storageprev;
if (storageprev != NULL)
storageprev->next = storage;
if (!(params->device_flags & DEVICE_FLAG_BROKEN_SEND_OBJECT_PROPLIST) &&
ptp_operation_issupported(params,PTP_OC_MTP_SendObjectPropList)) {
MTPProperties *props = (MTPProperties*)calloc(2,sizeof(MTPProperties));
+ if (props == NULL)
+ return -1;
props[0].property = PTP_OPC_ObjectFileName;
props[0].datatype = PTP_DTC_STR;
unsigned char *app1_marker = NULL;
ExifData *exif_data = NULL;
+ PTP_USB *ptp_usb = (PTP_USB*) device->usbinfo;
+
+ int oldtimeout;
+
+ get_usb_device_timeout(ptp_usb, &oldtimeout);
+
if (!ptp_operation_issupported(params, PTP_OC_GetPartialObject)) {
LIBMTP_INFO("ptp_operation_issupported fail - id %d", id);
return -1;
}
//Get App1 Marker header
+ set_usb_device_timeout(ptp_usb, 3000);
+
ret = ptp_getpartialobject (params, id, 0, 10, &jpeg_header, &jpeg_header_size);
if (ret != PTP_RC_OK) {
LIBMTP_INFO("first ptp_getpartialobject fail - id %d", id);
+ set_usb_device_timeout(ptp_usb, oldtimeout);
return -5;
}
+ set_usb_device_timeout(ptp_usb, oldtimeout);
+
if (!((jpeg_header[0] == 0xff) && (jpeg_header[1] == 0xd8))) { /* 0XFF 0xD8 means SOI (Start Of Image) */
LIBMTP_INFO("SOI fail - id %d", id);
free(jpeg_header);
LIBMTP_INFO("maxbytes is %d", maxbytes);
//Get App1 Marker : EXIF Data
+ set_usb_device_timeout(ptp_usb, 3000);
+
ret = ptp_getpartialobject (params, id, offset, maxbytes, &app1_marker, &app1_marker_size);
if (ret != PTP_RC_OK) {
LIBMTP_INFO("second ptp_getpartialobject fail - id %d", id);
+ set_usb_device_timeout(ptp_usb, oldtimeout);
return -9;
}
+ set_usb_device_timeout(ptp_usb, oldtimeout);
+
if (app1_marker == NULL) {
LIBMTP_INFO("app1_marker is NULL - id %d", id);
return -10;
}
*object_list = (uint32_t *)malloc(currentHandles.n * sizeof(int));
+ if (*object_list == NULL) {
+ LIBMTP_INFO("object list is NULL");
+ return -4;
+ }
for (i = 0; i < currentHandles.n; i++) {
if(_is_exist_handler(object_list, temp, currentHandles.Handler[i]))
}
object_info = (MTPObjectInfo *)malloc(sizeof(MTPObjectInfo));
+ if (object_info == NULL)
+ return NULL;
ret = ptp_object_want(params, object_id, PTPOBJECT_OBJECTINFO_LOADED, &ob);