From 0b17eba47f72790861be4a2e7a0f54cd9e027506 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Sun, 14 May 2017 11:33:22 +0200 Subject: 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 1967450b0..56326d572 100644 --- a/camlibs/ptp2/config.c +++ b/camlibs/ptp2/config.c @@ -7983,6 +7983,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 ); @@ -8006,8 +8008,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); -- cgit v1.2.1