Commit 6e664d3cb6701fb1a4b55e2ee3aa90406a467135

Thomas de Grivel 2024-03-02T18:33:10

fix map_init

diff --git a/libc3/map.c b/libc3/map.c
index 152471a..fb6181d 100644
--- a/libc3/map.c
+++ b/libc3/map.c
@@ -134,6 +134,7 @@ s_map * map_init_copy (s_map *map, const s_map *src)
       goto ko;
     i++;
   }
+  *map = tmp;
   return map;
  ko:
   map_clean(&tmp);
@@ -167,11 +168,12 @@ s_map * map_init_from_lists (s_map *map, const s_list *keys,
     v = list_next(v);
     i++;
   }
-  if (! map_sort(map))
+  if (! map_sort(&tmp))
     goto ko;
+  *map = tmp;
   return map;
  ko:
-  map_clean(map);
+  map_clean(&tmp);
   return NULL;
 }