From 1728254f3a51b8b4d7de902dd53f12141085109c Mon Sep 17 00:00:00 2001 From: BALATON Zoltan Date: Tue, 12 Jul 2016 23:34:27 +0200 Subject: Remove some unneded variables and conditionals and plug some potential memory leaks --- src/normal.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/normal.c') diff --git a/src/normal.c b/src/normal.c index c0ec2bf..8101b72 100644 --- a/src/normal.c +++ b/src/normal.c @@ -220,14 +220,13 @@ int normal_open_with_timeout(struct idevicerestore_client_t* client) { const char* normal_check_hardware_model(struct idevicerestore_client_t* client) { idevice_t device = NULL; - char* product_type = NULL; - irecv_device_t irecv_device = NULL; lockdownd_client_t lockdown = NULL; lockdownd_error_t lockdown_error = LOCKDOWN_E_SUCCESS; + irecv_device_t irecv_device = NULL; normal_idevice_new(client, &device); if (!device) { - return product_type; + return NULL; } lockdown_error = lockdownd_client_new_with_handshake(device, &lockdown, "idevicerestore"); @@ -236,22 +235,23 @@ const char* normal_check_hardware_model(struct idevicerestore_client_t* client) } if (lockdown_error != LOCKDOWN_E_SUCCESS) { idevice_free(device); - return product_type; + return NULL; } plist_t pval = NULL; lockdownd_get_value(lockdown, NULL, "HardwareModel", &pval); if (pval && (plist_get_node_type(pval) == PLIST_STRING)) { - char* strval = NULL; + char *strval = NULL; plist_get_string_val(pval, &strval); if (strval) { irecv_devices_get_device_by_hardware_model(strval, &irecv_device); free(strval); } } - if (pval) { - plist_free(pval); - } + plist_free(pval); + + lockdownd_client_free(lockdown); + idevice_free(device); return (irecv_device) ? irecv_device->hardware_model : NULL; } -- cgit v1.1-32-gdbae