aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2019-07-15 10:52:13 +0100
committerKatharina Fey <kookie@spacekookie.de>2019-07-15 10:52:13 +0100
commit7e59c771569e6162f2ef96b1d88c85f05cc0e552 (patch)
treea8c9922d9f93d85a3ac336daa333874f71d5fca6
parent0a97a1613bf42dc4ecaffbed1426d3495f5f9160 (diff)
Fixing a memory allocation regression
In a previous commit, adding HASH node support, this code was added that would let both ARRAY and HASH nodes allocate an array. The syntax was however wrong, never allocating memory and thus failing with an INVALID_STATE when freeing. Additionally, this begs the question how a cleanup of INVALID_STATE could be handled (i.e. with a `goto fail` in the `bowl_free` function)
-rw-r--r--bowl.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/bowl.c b/bowl.c
index 248ac37..9d12c69 100644
--- a/bowl.c
+++ b/bowl.c
@@ -31,7 +31,8 @@ err_t bowl_malloc(struct bowl **ptr, bowl_t type)
switch((*ptr)->type) {
case LEAF: return OK; // No further allocation needed
- case ARRAY | HASH: return array_malloc(*ptr, ARRAY_START_SIZE);
+ case ARRAY:
+ case HASH: return array_malloc(*ptr, ARRAY_START_SIZE);
default: return INVALID_STATE;
}