about summary refs log tree commit diff homepage
path: root/tools
diff options
context:
space:
mode:
authorCristian Cadar <c.cadar@imperial.ac.uk>2022-09-24 20:24:43 +0100
committerMartinNowack <2443641+MartinNowack@users.noreply.github.com>2022-12-09 12:30:12 +0000
commitf11aae61dc582c32a40816edb02df196e71b9874 (patch)
treeae348828ea9315da1ebd8c0bce3a8530db0858d4 /tools
parent7a60192729704f2a84645bb70b0c4188f93f7f92 (diff)
downloadklee-f11aae61dc582c32a40816edb02df196e71b9874.tar.gz
Fixed some leaks in klee-replay
Diffstat (limited to 'tools')
-rw-r--r--tools/klee-replay/klee-replay.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/tools/klee-replay/klee-replay.c b/tools/klee-replay/klee-replay.c
index 8af90e98..72eeb17e 100644
--- a/tools/klee-replay/klee-replay.c
+++ b/tools/klee-replay/klee-replay.c
@@ -311,10 +311,12 @@ int main(int argc, char** argv) {
 
       prg_argc = input->numArgs;
       prg_argv = input->args;
-      prg_argv[0] = argv[1];
+      free(prg_argv[0]);
+      prg_argv[0] = strdup(argv[1]);
       klee_init_env(&prg_argc, &prg_argv);
 
       replay_create_files(&__exe_fs);
+      kTest_free(input);
       return 0;
     }
 
@@ -366,8 +368,11 @@ int main(int argc, char** argv) {
     obj_index = 0;
     prg_argc = input->numArgs;
     prg_argv = input->args;
-    prg_argv[0] = argv[optind];
+    free(prg_argv[0]);
+    prg_argv[0] = strdup(argv[optind]);
+
     klee_init_env(&prg_argc, &prg_argv);
+
     if (idx > 2)
       fputc('\n', stderr);
     fprintf(stderr, "KLEE-REPLAY: NOTE: Test file: %s\n"
@@ -385,6 +390,7 @@ int main(int argc, char** argv) {
     /* Run the test case machinery in a subprocess, eventually this parent
        process should be a script or something which shells out to the actual
        execution tool. */
+
     int pid = fork();
     if (pid < 0) {
       perror("fork");
@@ -408,6 +414,9 @@ int main(int argc, char** argv) {
         perror("waitpid");
         _exit(66);
       }
+
+      free(prg_argv);
+      kTest_free(input);
     }
   }