summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Backtrace/main.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Backtrace/main.c b/src/Backtrace/main.c
index 6683aa9..cddf897 100644
--- a/src/Backtrace/main.c
+++ b/src/Backtrace/main.c
@@ -157,15 +157,27 @@ int main(int argc, char **argv)
exit(EX_IOERR);
}
+ /* Handle the case that the input file is empty.
+ * The code is not designed to support completely empty backtrace.
+ * Silently exit indicating success.
+ */
+ if (size == 0)
+ {
+ fclose(fp);
+ exit(0);
+ }
+
bttext = malloc(size + 1);
if (!bttext)
{
+ fclose(fp);
fputs("malloc failed", stderr);
exit(EX_OSERR);
}
if (1 != fread(bttext, size, 1, fp))
{
+ fclose(fp);
fprintf(stderr, "Unable to read from '%s'.\n", arguments.filename);
exit(EX_IOERR); /* IO Error */
}