Mercurial > hg > th-libs
changeset 705:dee28d507da7
Plug a memory leak.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 27 Apr 2020 00:11:28 +0300 |
parents | b6b8e7249666 |
children | d289fae3c1a8 |
files | th_regex.c |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/th_regex.c Sun Apr 26 23:34:21 2020 +0300 +++ b/th_regex.c Mon Apr 27 00:11:28 2020 +0300 @@ -196,13 +196,15 @@ static int th_regex_parse_ctx_node_commit(th_regex_parse_ctx_t *ctx, th_regex_node_t *node) { - th_regex_t *data = ctx->data; + th_regex_t *data; - if (data == NULL) + if (ctx->data == NULL) { if ((data = ctx->data = th_malloc0(sizeof(th_regex_t))) == NULL) return THERR_MALLOC; } + else + data = ctx->data; if (data->nodes == NULL || data->nnodes + 1 >= data->nodessize) { @@ -730,6 +732,7 @@ { th_regex_node_t *node = &expr->nodes[nnode]; + th_free(node->match.str); th_regex_free(node->match.expr); th_regex_list_free(&node->match.list); }