summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2014-03-23 16:19:06 +0000
committerMarcus Meissner <marcus@jet.franken.de>2014-03-23 16:19:06 +0000
commit889c4770aed571530d61cc48e03a7f1672d708be (patch)
treedcb7316d4450d2e76a1cc2b5c53632a2995a0d29
parent9e5eeb114e76b681e56e5493e9bccba5d560d8f6 (diff)
downloadlibgphoto2-889c4770aed571530d61cc48e03a7f1672d708be.tar.gz
free the cached device propdescs on exit, and
on cache refresh (leak). free the raw canon eos getobjectinfoex data after use (leak). git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@14846 67ed7778-7388-44ab-90cf-0a291f65f57c
-rw-r--r--camlibs/ptp2/ptp.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/camlibs/ptp2/ptp.c b/camlibs/ptp2/ptp.c
index 26646b9cb..c3a0174fe 100644
--- a/camlibs/ptp2/ptp.c
+++ b/camlibs/ptp2/ptp.c
@@ -757,6 +757,8 @@ parse_9301_prop_tree (PTPParams *params, xmlNodePtr node, PTPDeviceInfo *di) {
memset(&params->deviceproperties[i],0,sizeof(params->deviceproperties[0]));
params->nrofdeviceproperties++;
params->deviceproperties[i].prop = p;
+ } else {
+ ptp_free_devicepropdesc (&params->deviceproperties[i].desc);
}
/* FIXME: free old entry */
/* we are not using dpd, so copy it directly to the cache */
@@ -1075,6 +1077,7 @@ ptp_free_devicepropdesc(PTPDevicePropDesc* dpd)
free (dpd->FORM.Enum.SupportedValue);
}
}
+ dpd->DataType = PTP_DTC_UNDEF;
}
@@ -1137,6 +1140,11 @@ ptp_free_params (PTPParams *params) {
}
free (params->canon_props);
free (params->backlogentries);
+
+ for (i=0;i<params->nrofdeviceproperties;i++)
+ ptp_free_devicepropdesc (&params->deviceproperties[i].desc);
+ free (params->deviceproperties);
+
ptp_free_DI (&params->deviceinfo);
}
@@ -2486,14 +2494,17 @@ ptp_canon_eos_getobjectinfoex (
*nrofentries = dtoh32a(data);
*entries = malloc(*nrofentries * sizeof(PTPCANONFolderEntry));
- if (!*entries)
+ if (!*entries) {
+ free (data);
return PTP_RC_GeneralError;
+ }
xdata = data+sizeof(uint32_t);
for (i=0;i<*nrofentries;i++) {
ptp_unpack_Canon_EOS_FE (params, &xdata[4], &((*entries)[i]));
xdata += dtoh32a(xdata);
}
+ free (data);
return PTP_RC_OK;
}
@@ -3088,6 +3099,8 @@ ptp_generic_getdevicepropdesc (PTPParams *params, uint16_t propcode, PTPDevicePr
duplicate_DevicePropDesc(&params->deviceproperties[i].desc, dpd);
return PTP_RC_OK;
}
+ /* free cached entry as we will refetch it. */
+ ptp_free_devicepropdesc (&params->deviceproperties[i].desc);
}
if ( (params->deviceinfo.VendorExtensionID == PTP_VENDOR_SONY) &&