Skip to content

Commit

Permalink
Fix use after free (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
gerlachs authored Sep 20, 2023
1 parent 211c342 commit 718d491
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/bin/readstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,18 +397,21 @@ static int convert_file(const char *input_filename, const char *catalog_filename
module->finish(rs_ctx->module_ctx);
}

free(rs_ctx);

if (error != READSTAT_OK) {
if (file_exists) {
fprintf(stderr, "Error opening %s: File exists (Use -f to overwrite)\n", output_filename);
} else {
fprintf(stderr, "Error processing %s: %s\n", rs_ctx->error_filename, readstat_error_message(error));
unlink(output_filename);
}

free(rs_ctx);

return 1;
}

free(rs_ctx);

return 0;
}

Expand Down

0 comments on commit 718d491

Please sign in to comment.