From 1e5b90bd43d2a5f4a46c14f809f8493ee5ed9469 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Sun, 14 May 2017 11:33:22 +0200 Subject: [PATCH] set_config: free device property value only when actually set. initialize it to 0 to avoid double frees fixes https://github.com/gphoto/libgphoto2/issues/167 --- camlibs/ptp2/config.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/camlibs/ptp2/config.c b/camlibs/ptp2/config.c index 6b2307d978..96f67e2c4c 100644 --- a/camlibs/ptp2/config.c +++ b/camlibs/ptp2/config.c @@ -7987,6 +7987,8 @@ _set_config (Camera *camera, const char *confname, CameraWidget *window, GPConte PTPDevicePropDesc dpd; memset(&dpd,0,sizeof(dpd)); + memset(&propval,0,sizeof(propval)); + C_PTP (ptp_generic_getdevicepropdesc(params,cursub->propid,&dpd)); if (cursub->type != dpd.DataType) { GP_LOG_E ("Type of property '%s' expected: 0x%04x got: 0x%04x", cursub->label, cursub->type, dpd.DataType ); @@ -8010,8 +8012,8 @@ _set_config (Camera *camera, const char *confname, CameraWidget *window, GPConte _(cursub->label), cursub->propid, ret_ptp, _(ptp_strerror(ret_ptp, params->deviceinfo.VendorExtensionID))); ret = translate_ptp_result (ret_ptp); } + ptp_free_devicepropvalue (cursub->type, &propval); } - ptp_free_devicepropvalue (cursub->type, &propval); ptp_free_devicepropdesc(&dpd); } else { ret = cursub->putfunc (camera, widget, NULL, NULL);