aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2026-04-21 21:34:40 +0300
committerSyndamia <kamen@syndamia.com>2026-04-21 21:35:17 +0300
commit9b1695b9f2eda40c61bd201607d9296ebaf37c78 (patch)
treefe005402c18b65149948779043947c8575dbbd03
parent6e7d4efab4e3b35a68dfd5cfbeda6373b86520ff (diff)
downloadfoollib-9b1695b9f2eda40c61bd201607d9296ebaf37c78.tar
foollib-9b1695b9f2eda40c61bd201607d9296ebaf37c78.tar.gz
foollib-9b1695b9f2eda40c61bd201607d9296ebaf37c78.zip
fix(A_new): Handle out of memory condition
-rw-r--r--Array.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Array.c b/Array.c
index 2df6d0b..60dc82d 100644
--- a/Array.c
+++ b/Array.c
@@ -31,6 +31,9 @@ A_new(BumpArena b, usize element_size, usize length) {
};
void* start = B_alloc(b, sizeof(am) + element_size * length);
+ if (NULL == start)
+ return NULL;
+
memcpy(start, &am, sizeof(am));
return start + sizeof(am);
}