From 8b71e0945b6ab843b3528b03fdb22d6ff02b0c55 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 24 Sep 2013 19:35:27 +0200 Subject: recovery: fix possible segfault and plug some small memory leaks --- src/recovery.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/recovery.c') diff --git a/src/recovery.c b/src/recovery.c index 3edba5c..a1001dd 100644 --- a/src/recovery.c +++ b/src/recovery.c @@ -170,16 +170,32 @@ int recovery_enter_restore(struct idevicerestore_client_t* client, plist_t build info("Recovery Mode Environment:\n"); char* value = NULL; irecv_getenv(client->recovery->client, "build-version", &value); - info("iBoot build-version=%s\n", value); + info("iBoot build-version=%s\n", (value) ? value : "(unknown)"); + if (value) { + free(value); + value = NULL; + } irecv_getenv(client->recovery->client, "build-style", &value); - info("iBoot build-style=%s\n", value); + info("iBoot build-style=%s\n", (value) ? value : "(unknown)"); + if (value) { + free(value); + value = NULL; + } unsigned long radio_error = 0; irecv_getenv(client->recovery->client, "radio-error", &value); - radio_error = strtoul(value, NULL, 0); + if (value) { + radio_error = strtoul(value, NULL, 0); + } if (radio_error > 0) { info("radio-error=%s\n", value); + free(value); + value = NULL; irecv_getenv(client->recovery->client, "radio-error-string", &value); - info("radio-error-string=%s\n", value); + if (value) { + info("radio-error-string=%s\n", value); + free(value); + value = NULL; + } } /* send logo and show it */ -- cgit v1.1-32-gdbae