diff --git a/camlibs/ptp2/library.c b/camlibs/ptp2/library.c index 3a5af68ac..f1b5e717c 100644 --- a/camlibs/ptp2/library.c +++ b/camlibs/ptp2/library.c @@ -327,7 +327,11 @@ fixup_cached_deviceinfo (Camera *camera, PTPDeviceInfo *di) { unsigned int xsize; C_PTP (ptp_nikon_get_vendorpropcodes (&camera->pl->params, &xprops, &xsize)); - C_MEM (di->DevicePropertiesSupported = realloc(di->DevicePropertiesSupported,sizeof(di->DevicePropertiesSupported[0])*(di->DevicePropertiesSupported_len + xsize))); + di->DevicePropertiesSupported = realloc(di->DevicePropertiesSupported,sizeof(di->DevicePropertiesSupported[0])*(di->DevicePropertiesSupported_len + xsize)); + if (!di->DevicePropertiesSupported) { + free (xprops); + C_MEM (di->DevicePropertiesSupported); + } for (i=0;iDevicePropertiesSupported[i+di->DevicePropertiesSupported_len] = xprops[i]; di->DevicePropertiesSupported_len += xsize;