Fix potential memory leaks found by the Clang static analyzer.

This commit is contained in:
Guus Sliepen 2016-06-23 15:59:43 +02:00
parent 49edf9c53a
commit b9b0defaf4

View file

@ -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;