diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-10-19 13:53:47 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-10-19 13:53:47 +0200 |
commit | 338d02300970d76ce76e789ab3c8210f9abd927c (patch) | |
tree | fd648f6cc51fb9baad7c839f06c9ed3426b7c3c5 | |
parent | 036ba87c5d18385c5da13c331658363ea0ba6afe (diff) |
ast: fix scope double free in ut_free()
Zero the scope object pointer in the scope structure before putting the
JSON object in order to avoid a double-free by the scope's userdata
destructor function.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r-- | ast.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -525,6 +525,7 @@ ut_free(struct ut_state *s) { struct ut_source *src, *src_next; struct ut_scope *sc, *sc_next; + struct json_object *scj; size_t n; if (s) { @@ -547,8 +548,9 @@ ut_free(struct ut_state *s) json_object_put(s->rval); for (sc = s->scopelist; sc; sc = sc->next) { - json_object_put(sc->scope); + scj = sc->scope; sc->scope = NULL; + json_object_put(scj); } for (sc = s->scopelist; sc; sc = sc_next) { |