Skip to content

Commit

Permalink
Fix segmentation fault on file open errors
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Aug 23, 2020
1 parent e42d8da commit e7c37d7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ seq2gif_CFLAGS = $(MAYBE_COVERAGE)

test: all
./seq2gif -i tests/data/sl.tty -o /dev/null
! ./seq2gif -i /non-existent-file.tty -o /dev/null
! ./seq2gif -i tests/data/sl.tty -o /non-existent-file.out

coveralls: test
coveralls -E '.*\.h' -e tests -e glyph -e m4
Expand Down
2 changes: 2 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,8 @@ uninstall-am: uninstall-binPROGRAMS

test: all
./seq2gif -i tests/data/sl.tty -o /dev/null
! ./seq2gif -i /non-existent-file.tty -o /dev/null
! ./seq2gif -i tests/data/sl.tty -o /non-existent-file.out

coveralls: test
coveralls -E '.*\.h' -e tests -e glyph -e m4
Expand Down
3 changes: 3 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,9 @@ int main(int argc, char *argv[])

in_file = open_input_file(settings.input);
out_file = open_output_file(settings.output);
if (in_file == NULL || out_file == NULL) {
exit(1);
}

maxlen = 2048;
obuf = malloc(maxlen);
Expand Down

0 comments on commit e7c37d7

Please sign in to comment.