summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2018-01-03 02:42:25 +0100
committerGravatar Nikias Bassen2018-01-03 02:42:25 +0100
commitf78fc4a11b81bcb2aacf93a2060f15fa2f99b66a (patch)
tree0b5bddb32069dbcad0a6a52715220c7e12c569b9
parentf06b60e5c1f0ea3ebfdf5684cb884be5c49acee7 (diff)
downloadlibirecovery-f78fc4a11b81bcb2aacf93a2060f15fa2f99b66a.tar.gz
libirecovery-f78fc4a11b81bcb2aacf93a2060f15fa2f99b66a.tar.bz2
Remove some unnecessary null pointer checks
-rw-r--r--src/libirecovery.c44
-rw-r--r--tools/irecovery.c3
2 files changed, 15 insertions, 32 deletions
diff --git a/src/libirecovery.c b/src/libirecovery.c
index 69b430c..ae4e3c7 100644
--- a/src/libirecovery.c
+++ b/src/libirecovery.c
@@ -527,10 +527,8 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, unsigned long long ec
527 memset(&currentInterface, '\0', sizeof(SP_DEVICE_INTERFACE_DATA)); 527 memset(&currentInterface, '\0', sizeof(SP_DEVICE_INTERFACE_DATA));
528 currentInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); 528 currentInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
529 for(i = 0; usbDevices && SetupDiEnumDeviceInterfaces(usbDevices, NULL, &GUID_DEVINTERFACE_DFU, i, &currentInterface); i++) { 529 for(i = 0; usbDevices && SetupDiEnumDeviceInterfaces(usbDevices, NULL, &GUID_DEVINTERFACE_DFU, i, &currentInterface); i++) {
530 if (_client->DfuPath) { 530 free(_client->DfuPath);
531 free(_client->DfuPath); 531 _client->DfuPath = NULL;
532 _client->DfuPath = NULL;
533 }
534 _client->handle = NULL; 532 _client->handle = NULL;
535 DWORD requiredSize = 0; 533 DWORD requiredSize = 0;
536 PSP_DEVICE_INTERFACE_DETAIL_DATA details; 534 PSP_DEVICE_INTERFACE_DETAIL_DATA details;
@@ -614,10 +612,8 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, unsigned long long ec
614 memset(&currentInterface, '\0', sizeof(SP_DEVICE_INTERFACE_DATA)); 612 memset(&currentInterface, '\0', sizeof(SP_DEVICE_INTERFACE_DATA));
615 currentInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); 613 currentInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
616 for(i = 0; usbDevices && SetupDiEnumDeviceInterfaces(usbDevices, NULL, &GUID_DEVINTERFACE_IBOOT, i, &currentInterface); i++) { 614 for(i = 0; usbDevices && SetupDiEnumDeviceInterfaces(usbDevices, NULL, &GUID_DEVINTERFACE_IBOOT, i, &currentInterface); i++) {
617 if (_client->iBootPath) { 615 free(_client->iBootPath);
618 free(_client->iBootPath); 616 _client->iBootPath = NULL;
619 _client->iBootPath = NULL;
620 }
621 _client->handle = NULL; 617 _client->handle = NULL;
622 DWORD requiredSize = 0; 618 DWORD requiredSize = 0;
623 PSP_DEVICE_INTERFACE_DETAIL_DATA details; 619 PSP_DEVICE_INTERFACE_DETAIL_DATA details;
@@ -1550,28 +1546,17 @@ IRECV_API irecv_error_t irecv_close(irecv_client_t client) {
1550 } 1546 }
1551#endif 1547#endif
1552#else 1548#else
1553 if (client->iBootPath!=NULL) { 1549 free(client->iBootPath);
1554 free(client->iBootPath); 1550 client->iBootPath = NULL;
1555 client->iBootPath = NULL; 1551 free(client->DfuPath);
1556 } 1552 client->DfuPath = NULL;
1557 if (client->DfuPath!=NULL) {
1558 free(client->DfuPath);
1559 client->DfuPath = NULL;
1560 }
1561 mobiledevice_closepipes(client); 1553 mobiledevice_closepipes(client);
1562#endif 1554#endif
1563 if (client->device_info.srnm) { 1555 free(client->device_info.srnm);
1564 free(client->device_info.srnm); 1556 free(client->device_info.imei);
1565 } 1557 free(client->device_info.ap_nonce);
1566 if (client->device_info.imei) { 1558 free(client->device_info.sep_nonce);
1567 free(client->device_info.imei); 1559
1568 }
1569 if (client->device_info.ap_nonce) {
1570 free(client->device_info.ap_nonce);
1571 }
1572 if (client->device_info.sep_nonce) {
1573 free(client->device_info.sep_nonce);
1574 }
1575 free(client); 1560 free(client);
1576 client = NULL; 1561 client = NULL;
1577 } 1562 }
@@ -2040,8 +2025,7 @@ IRECV_API irecv_error_t irecv_execute_script(irecv_client_t client, const char*
2040 line = strtok(NULL, "\n"); 2025 line = strtok(NULL, "\n");
2041 } 2026 }
2042 2027
2043 if (body) 2028 free(body);
2044 free(body);
2045 2029
2046 return error; 2030 return error;
2047} 2031}
diff --git a/tools/irecovery.c b/tools/irecovery.c
index 0db60e4..f250dc5 100644
--- a/tools/irecovery.c
+++ b/tools/irecovery.c
@@ -299,8 +299,7 @@ int postcommand_cb(irecv_client_t client, const irecv_event_t* event) {
299 } 299 }
300 } 300 }
301 301
302 if (command) 302 free(command);
303 free(command);
304 303
305 return 0; 304 return 0;
306} 305}