# HG changeset patch # User Matti Hamalainen # Date 1587935488 -10800 # Node ID dee28d507da7ae079fab4d0ca2180326fc1d7ac3 # Parent b6b8e7249666296263e258bf6bb7c03a8eb8897d Plug a memory leak. diff -r b6b8e7249666 -r dee28d507da7 th_regex.c --- 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); }