From: Ran Benita Date: Wed, 28 May 2014 17:32:16 +0000 (+0300) Subject: rules: fix leak on failure X-Git-Tag: xkbcommon-0.4.3~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d6f2d8ecd07984a2c8725090acb806a16b51738a;p=platform%2Fupstream%2Flibxkbcommon.git rules: fix leak on failure matcher_match() builds up the kccgst's, and we steal the memory on success. But on error we didn't free it. Signed-off-by: Ran Benita --- diff --git a/src/xkbcomp/rules.c b/src/xkbcomp/rules.c index 61799e7..39125da 100644 --- a/src/xkbcomp/rules.c +++ b/src/xkbcomp/rules.c @@ -309,6 +309,8 @@ matcher_free(struct matcher *m) darray_free(m->rmlvo.options); darray_foreach(group, m->groups) darray_free(group->elements); + for (int i = 0; i < _KCCGST_NUM_ENTRIES; i++) + darray_free(m->kccgst[i]); darray_free(m->groups); free(m); } @@ -950,6 +952,8 @@ finish: /* out->geometry = darray_mem(m->kccgst[KCCGST_GEOMETRY], 0); */ darray_free(m->kccgst[KCCGST_GEOMETRY]); out->symbols = darray_mem(m->kccgst[KCCGST_SYMBOLS], 0); + for (int i = 0; i < _KCCGST_NUM_ENTRIES; i++) + darray_init(m->kccgst[i]); return true;