From: Guus Sliepen Date: Thu, 23 Jun 2016 13:59:43 +0000 (+0200) Subject: Fix potential memory leaks found by the Clang static analyzer. X-Git-Tag: release-1.1pre15~62 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=b9b0defaf422bcc1272f87d791d9ac53c9539734;p=tinc Fix potential memory leaks found by the Clang static analyzer. --- diff --git a/src/tincctl.c b/src/tincctl.c index a0a7633d..465c9813 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -2521,6 +2521,7 @@ static int cmd_verify(int argc, char *argv[]) { char *newline = memchr(data, '\n', len); if(!newline || (newline - data > MAX_STRING_SIZE - 1)) { fprintf(stderr, "Invalid input\n"); + free(data); return 1; } @@ -2533,11 +2534,13 @@ static int cmd_verify(int argc, char *argv[]) { if(sscanf(data, "Signature = %s %ld %s", signer, &t, sig) != 3 || strlen(sig) != 86 || !t || !check_id(signer)) { fprintf(stderr, "Invalid input\n"); + free(data); return 1; } if(node && strcmp(node, signer)) { fprintf(stderr, "Signature is not made by %s\n", node); + free(data); return 1; } @@ -2831,8 +2834,10 @@ static int cmd_shell(int argc, char *argv[]) { if(nargc == argc) continue; - if(!strcasecmp(nargv[argc], "exit") || !strcasecmp(nargv[argc], "quit")) + if(!strcasecmp(nargv[argc], "exit") || !strcasecmp(nargv[argc], "quit")) { + free(nargv); return result; + } bool found = false;