trace: fix potential use-after-free occurence
[project/procd.git] / trace / trace.c
index 87a98a632b5e42eb041357dce417022239006282..40cf3df5b9adc031bd04a34e2beec401728fee00 100644 (file)
@@ -166,8 +166,8 @@ static void print_syscalls(int policy, const char *json)
                        if (!tmp)
                                return;
 
-                       free(tmp);
                        fprintf(fp, "%s\n", tmp);
+                       free(tmp);
                        fclose(fp);
                        ULOG_INFO("saving syscall trace to %s\n", json);
                } else {