Commit 88285e3e6ed2f4867832f8978427e6a73d0cd581

Thomas de Grivel 2024-07-23T15:39:56

wip asan

diff --git a/libkc3/env.c b/libkc3/env.c
index 86775d5..532ea0c 100644
--- a/libkc3/env.c
+++ b/libkc3/env.c
@@ -121,8 +121,8 @@ bool env_call_get (s_env *env, s_call *call)
       facts_cursor_clean(&cursor);
       return false;
     }
+    facts_cursor_clean(&cursor);
   }
-  facts_cursor_clean(&cursor);
   if (! facts_find_fact_by_tags(&env->facts, &tag_ident, &tag_is_a,
                                 &tag_macro, &fact))
     return false;
@@ -2892,7 +2892,6 @@ const s_struct_type ** env_struct_type_find (s_env *env,
     return NULL;
   }
   if (! found) {
-    facts_with_cursor_clean(&cursor);
     *dest = NULL;
     return dest;
   }
diff --git a/libkc3/struct.c b/libkc3/struct.c
index d35f459..935dedd 100644
--- a/libkc3/struct.c
+++ b/libkc3/struct.c
@@ -212,8 +212,11 @@ s_struct * struct_init_copy (s_struct *s, const s_struct *src)
       return NULL;
     i = 0;
     while (i < tmp.type->map.count) {
-      if (! tag_type(tmp.type->map.value + i, &sym) ||
-          ! data_init_copy(sym, (s8 *) tmp.data + tmp.type->offset[i],
+      if (tmp.type->map.value[i].type == TAG_VAR)
+        sym = tmp.type->map.value[i].data.var.type;
+      else if (! tag_type(tmp.type->map.value + i, &sym))
+        goto ko;
+      if (! data_init_copy(sym, (s8 *) tmp.data + tmp.type->offset[i],
                            (s8 *) src->data + tmp.type->offset[i]))
         goto ko;
       i++;