blob: 70ea38ffd15647b1aa1b567143ab55eeae706379 (
plain) (
tree)
|
|
From 718d49155e327471ed9bf4a8c157f849f285b46c Mon Sep 17 00:00:00 2001
From: Stefan Gerlach <stefan.gerlach@uni-konstanz.de>
Date: Wed, 20 Sep 2023 15:18:07 +0200
Subject: [PATCH] Fix use after free (#298)
---
src/bin/readstat.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/bin/readstat.c b/src/bin/readstat.c
index 48b8fdd..e3fbbd1 100644
--- a/src/bin/readstat.c
+++ b/src/bin/readstat.c
@@ -397,8 +397,6 @@ 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);
@@ -406,9 +404,14 @@ static int convert_file(const char *input_filename, const char *catalog_filename
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;
}
|