Skip to content

Commit

Permalink
Fix possible NULL deref at quit
Browse files Browse the repository at this point in the history
  • Loading branch information
markwal committed May 3, 2016
1 parent d569338 commit ed7ccea
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/gpx/gpx-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,20 @@ static char temp_config_name[24];
static void exit_handler(void)
{
// close open files
if(file_in != stdin) {
if(file_in != stdin && file_in != NULL) {
fclose(file_in);
if(file_out != stdout) {
if(ferror(file_out)) {
perror("Error writing to output file");
}
fclose(file_out);
file_out = NULL;
}
if(file_out2) {
fclose(file_out2);
file_out2 = NULL;
file_in = NULL;
}
if(file_out != stdout && file_out != NULL) {
if(ferror(file_out)) {
perror("Error writing to output file");
}
fclose(file_out);
file_out = NULL;
}
if(file_out2 != NULL) {
fclose(file_out2);
file_out2 = NULL;
}

// 23 February 2015
Expand Down

0 comments on commit ed7ccea

Please sign in to comment.