diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-10-31 22:34:21 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-10-31 22:39:46 +0100 |
commit | be3a61d576581278177a4fcc4c436f99611ed057 (patch) | |
tree | 17368c1e41dd09b1b204c8c2da00c196382c6b68 | |
parent | 55578a56b73dff5374e4b9c59dcece96f86714f9 (diff) |
ast: fix potential null pointer deref in ut_free()
Extend the existing `s != NULL` conditional to cover all state pointer
accesses.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r-- | ast.c | 40 |
1 files changed, 20 insertions, 20 deletions
@@ -538,34 +538,34 @@ ut_free(struct ut_state *s) s->poolsize = 0; ut_reset(s); - } - - while (ut_ext_types_count > 0) - json_object_put(ut_ext_types[--ut_ext_types_count].proto); - json_object_put(s->rval); + json_object_put(s->rval); - for (sc = s->scopelist; sc; sc = sc->next) { - scj = sc->scope; - sc->scope = NULL; - json_object_put(scj); - } + for (sc = s->scopelist; sc; sc = sc->next) { + scj = sc->scope; + sc->scope = NULL; + json_object_put(scj); + } - for (sc = s->scopelist; sc; sc = sc_next) { - sc_next = sc->next; - free(sc); - } + for (sc = s->scopelist; sc; sc = sc_next) { + sc_next = sc->next; + free(sc); + } - for (src = s->sources; src; src = src_next) { - src_next = src->next; + for (src = s->sources; src; src = src_next) { + src_next = src->next; - if (src->fp) - fclose(src->fp); + if (src->fp) + fclose(src->fp); - free(src->filename); - free(src); + free(src->filename); + free(src); + } } + while (ut_ext_types_count > 0) + json_object_put(ut_ext_types[--ut_ext_types_count].proto); + free(ut_ext_types); free(s); } |