Skip to content

Commit

Permalink
set_config: free device property value only when actually set.
Browse files Browse the repository at this point in the history
initialize it to 0 to avoid double frees

fixes gphoto#167
  • Loading branch information
msmeissn committed May 14, 2017
1 parent 9a846ed commit 1e5b90b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion camlibs/ptp2/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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);
Expand Down

0 comments on commit 1e5b90b

Please sign in to comment.