Commit 16ed8dda75a3ad4002d33bb5f61a2c5475e74e21

Thomas de Grivel 2023-01-30T11:49:05

make test_asan

diff --git a/libc3/facts.c b/libc3/facts.c
index acded08..4dff40b 100644
--- a/libc3/facts.c
+++ b/libc3/facts.c
@@ -376,7 +376,7 @@ sw facts_open_file (s_facts *facts, const s8 *path)
   if ((r = facts_open_buf(facts, &in)) < 0)
     return r;
   result += r;
-  fclose(fp);
+  buf_file_close(&in);
   if (! (fp = fopen(path, "ab"))) {
     warn("fopen: %s", path);
     return -1;
@@ -513,6 +513,8 @@ sw facts_save_file (s_facts *facts, const s8 *path)
     goto ko;
   result += r;
   buf_flush(&buf);
+  free(buf.user_ptr);
+  buf.user_ptr = NULL;
   if (! (facts->log = log_new()))
     goto ko;
   if (log_open(facts->log, fp) < 0)