aboutsummaryrefslogtreecommitdiff
path: root/util/list.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-08-15 12:21:58 -0400
committerGitHub <noreply@github.com>2017-08-15 12:21:58 -0400
commit27c13d621df7b38d04f8ffb3012aa977d1b9bb24 (patch)
tree4cf9539672adb77ddc6ac2110a6f4458b386e9a1 /util/list.c
parentf60b53c6e3c91aefa432ce75deb89560a8e5c0d7 (diff)
parent5cc7342606dbbd5e6932b39e6b1b5645164669bf (diff)
Merge pull request #88 from 4e554c4c/alloc_crashing
Prevent alloc errors from crashing
Diffstat (limited to 'util/list.c')
-rw-r--r--util/list.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/util/list.c b/util/list.c
index e03c7498..44fba4db 100644
--- a/util/list.c
+++ b/util/list.c
@@ -6,9 +6,16 @@
list_t *list_create(void) {
list_t *list = malloc(sizeof(list_t));
+ if (!list) {
+ return NULL;
+ }
list->capacity = 10;
list->length = 0;
list->items = malloc(sizeof(void*) * list->capacity);
+ if (!list->items) {
+ free(list);
+ return NULL;
+ }
return list;
}