From 2bd5c199db8307f3e2e6f86dcbdd60c466ddb20b Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Sat, 16 Aug 2014 08:52:07 +0000 Subject: [PATCH] fixed memory leak in error case (Coverity) git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@15124 67ed7778-7388-44ab-90cf-0a291f65f57c --- camlibs/ptp2/library.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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;