From fbe5f413811df3712c2b3cd7c037afeb30313286 Mon Sep 17 00:00:00 2001 From: Chloe Kudryavtsev Date: Mon, 3 Apr 2023 16:09:48 -0400 Subject: native: fix non-zeroed initialization When we initialize an slist but it's meant to be empty, it might not be zero-allocated and thus recognize it's null. Therefore, explicitly zero-initialize jurl_cleanup->slist. --- src/cleanup.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/cleanup.c b/src/cleanup.c index abc55b7..f47c374 100644 --- a/src/cleanup.c +++ b/src/cleanup.c @@ -18,6 +18,17 @@ void jurl_do_cleanup(struct jurl_cleanup **src) { struct jurl_cleanup *register_cleanup(struct jurl_cleanup **prev, enum jurl_cleanup_type type) { struct jurl_cleanup *out = malloc(sizeof(struct jurl_cleanup)); + + switch (type) { + case JURL_CLEANUP_TYPE_SLIST: + out->slist = NULL; // we malloced + break; + default: + free(out); + janet_panic("unknown cleanup type in register_cleanup"); + return NULL; + } + out->next = *prev; *prev = out; out->type = type; -- cgit v1.2.3