summaryrefslogtreecommitdiffstats
path: root/src/normal.c
diff options
context:
space:
mode:
authorGravatar BALATON Zoltan2016-07-12 23:34:27 +0200
committerGravatar BALATON Zoltan2017-02-07 18:32:39 +0100
commit1728254f3a51b8b4d7de902dd53f12141085109c (patch)
tree286124ad1c242835c59522aba32141f4340c0988 /src/normal.c
parent00a9e576ebf0dec261c67644d6c7eba7ea9afd23 (diff)
downloadidevicerestore-1728254f3a51b8b4d7de902dd53f12141085109c.tar.gz
idevicerestore-1728254f3a51b8b4d7de902dd53f12141085109c.tar.bz2
Remove some unneded variables and conditionals and plug some potential memory leaks
Diffstat (limited to 'src/normal.c')
-rw-r--r--src/normal.c16
1 files changed, 8 insertions, 8 deletions
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;
}