fix cx_array_advanced_realloc to handle reallocation of NULL arrays, consistent with standard realloc behavior

Thu, 28 Nov 2024 19:37:00 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 28 Nov 2024 19:37:00 +0100
changeset 995
d3d4f245b843
parent 994
3603bdf4a78b
child 996
333155f234c4

fix cx_array_advanced_realloc to handle reallocation of NULL arrays, consistent with standard realloc behavior

src/array_list.c file | annotate | diff | comparison | revisions
--- a/src/array_list.c	Wed Nov 27 22:33:30 2024 +0100
+++ b/src/array_list.c	Thu Nov 28 19:37:00 2024 +0100
@@ -63,7 +63,7 @@
     void *newmem;
     if (array == alloc->ptr2) {
         newmem = cxMalloc(al, capacity * elem_size);
-        if (newmem != NULL) {
+        if (newmem != NULL && array != NULL) {
             memcpy(newmem, array, capacity * elem_size);
         }
     } else {

mercurial