clean: fix returning garbage in failure cases

The variable contents was not being properly set when early failures
happen in read_mom_contents.

Found with clang static analyzer.
This commit is contained in:
Caio Marcelo de Oliveira Filho
2018-04-03 09:12:45 -07:00
committed by Matthew Johnson
parent 7badf98216
commit a49e188288
+2 -1
View File
@@ -226,6 +226,7 @@ static char *read_mom_contents(int version)
return NULL;
}
char *contents = NULL;
int fd = fileno(f);
if (fd == -1) {
goto end;
@@ -238,7 +239,7 @@ static char *read_mom_contents(int version)
goto end;
}
char *contents = malloc(stat.st_size + 1);
contents = malloc(stat.st_size + 1);
if (!contents) {
goto end;
}