diff options
author | Karel Klic <kklic@redhat.com> | 2010-03-18 11:37:23 +0100 |
---|---|---|
committer | Karel Klic <kklic@redhat.com> | 2010-03-18 11:37:23 +0100 |
commit | 7bc2585fe81ce94d05a3b7c8045c0177a6fc70cc (patch) | |
tree | 5bf948e7450ff6b4032a9894a667445c830c2c01 /src/Backtrace/main.c | |
parent | e2d79ab74c2bfa798a3ec9772eb57bc4bcc7a7b8 (diff) | |
download | abrt-7bc2585fe81ce94d05a3b7c8045c0177a6fc70cc.tar.gz abrt-7bc2585fe81ce94d05a3b7c8045c0177a6fc70cc.tar.xz abrt-7bc2585fe81ce94d05a3b7c8045c0177a6fc70cc.zip |
Gracefully handle empty files in abrt-backtrace
Diffstat (limited to 'src/Backtrace/main.c')
-rw-r--r-- | src/Backtrace/main.c | 12 |
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 */ } |