Commit c827d68b166223ba6bbc1c6048f269b81d0c6d82

Thomas de Grivel 2023-09-19T22:36:16

fix u8.facts

diff --git a/lib/c3/0.1/u8.facts b/lib/c3/0.1/u8.facts
index 8726861..b87308b 100644
--- a/lib/c3/0.1/u8.facts
+++ b/lib/c3/0.1/u8.facts
@@ -3,5 +3,5 @@
 add {U8, :is_a, :module}
 add {U8, :symbol, U8.cast}
 add {U8, :symbol, U8.size}
-replace {U8.cast, :cfn, cfn :u8 "u8_cast" (:tag, :&result)}
+replace {U8.cast, :cfn, cfn :u8 "u8_cast" (:tag)}
 replace {U8.size, :value, 1}
diff --git a/libc3/array.c b/libc3/array.c
index 1bb2523..8c62d00 100644
--- a/libc3/array.c
+++ b/libc3/array.c
@@ -51,7 +51,12 @@ s_array * array_copy (const s_array *src, s_array *dest)
   }
 #endif
   dest->dimension = src->dimension;
-  dest->dimensions = calloc(src->dimension, sizeof(s_array_dimension));
+  if (! (dest->dimensions = calloc(src->dimension,
+                                   sizeof(s_array_dimension)))) {
+    assert(! "array_copy: out of memory: dimensions");
+    warnx("array_copy: out of memory: dimensions");
+    return NULL;
+  }
   memcpy(dest->dimensions, src->dimensions,
          src->dimension * sizeof(s_array_dimension));
   dest->count = src->count;
@@ -82,9 +87,10 @@ void * array_data (const s_array *a, const uw *address)
   uw offset = 0;
   assert(a);
   assert(address);
+  assert(a->data);
   while (i < a->dimension) {
     if (address[i] >= a->dimensions[i].count) {
-      errx(1, "array address overflow");
+      warnx("array_data: address overflow: %lu", i);
       return NULL;
     }
     offset += address[i] * a->dimensions[i].item_size;