diff options
author | Martin Szulecki | 2013-10-09 17:14:58 +0200 |
---|---|---|
committer | Martin Szulecki | 2013-10-09 17:14:58 +0200 |
commit | 9245f736a7f2d5ae0f24923c83949a5850844c21 (patch) | |
tree | 3b5a2bf473a11c1a8ac35466aaba920a4f09eaba /src | |
parent | 58e7581731f9baf42ebf80c1bde9780f6a4e1aab (diff) | |
download | usbmuxd-9245f736a7f2d5ae0f24923c83949a5850844c21.tar.gz usbmuxd-9245f736a7f2d5ae0f24923c83949a5850844c21.tar.bz2 |
preflight: Free version string in all cases to prevent memory leak
Diffstat (limited to 'src')
-rw-r--r-- | src/preflight.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/preflight.c b/src/preflight.c index b616e5f..44a59ff 100644 --- a/src/preflight.c +++ b/src/preflight.c @@ -118,6 +118,9 @@ static void* preflight_worker_handle_device_add(void* userdata) lockdownd_client_t lockdown = NULL; lockdownd_error_t lerr; + plist_t value = NULL; + char* version_str = NULL; + retry: lerr = lockdownd_client_new(dev, &lockdown, "usbmuxd"); if (lerr != LOCKDOWN_E_SUCCESS) { @@ -171,15 +174,16 @@ retry: break; } - plist_t value = NULL; lerr = lockdownd_get_value(lockdown, NULL, "ProductVersion", &value); if (lerr != LOCKDOWN_E_SUCCESS) { usbmuxd_log(LL_ERROR, "%s: ERROR: Could not get ProductVersion from device %s, lockdown error %d", __func__, _dev->udid, lerr); goto leave; } - char* version_str = NULL; - plist_get_string_val(value, &version_str); + if (value && plist_get_node_type(value) == PLIST_STRING) { + plist_get_string_val(value, &version_str); + } + if (!version_str) { usbmuxd_log(LL_ERROR, "%s: Could not get ProductVersion string from device %s handle %d", __func__, _dev->udid, (int)(long)_dev->conn_data); goto leave; @@ -277,6 +281,10 @@ retry: } leave: + if (value) + plist_free(value); + if (version_str) + free(version_str); if (lockdown) lockdownd_client_free(lockdown); if (dev) |