Mercurial > hg > th-libs
comparison th_regex.c @ 705:dee28d507da7
Plug a memory leak.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 27 Apr 2020 00:11:28 +0300 |
parents | 7493d4c9ff77 |
children | c91902120e79 |
comparison
equal
deleted
inserted
replaced
704:b6b8e7249666 | 705:dee28d507da7 |
---|---|
194 } | 194 } |
195 | 195 |
196 | 196 |
197 static int th_regex_parse_ctx_node_commit(th_regex_parse_ctx_t *ctx, th_regex_node_t *node) | 197 static int th_regex_parse_ctx_node_commit(th_regex_parse_ctx_t *ctx, th_regex_node_t *node) |
198 { | 198 { |
199 th_regex_t *data = ctx->data; | 199 th_regex_t *data; |
200 | 200 |
201 if (data == NULL) | 201 if (ctx->data == NULL) |
202 { | 202 { |
203 if ((data = ctx->data = th_malloc0(sizeof(th_regex_t))) == NULL) | 203 if ((data = ctx->data = th_malloc0(sizeof(th_regex_t))) == NULL) |
204 return THERR_MALLOC; | 204 return THERR_MALLOC; |
205 } | 205 } |
206 else | |
207 data = ctx->data; | |
206 | 208 |
207 if (data->nodes == NULL || data->nnodes + 1 >= data->nodessize) | 209 if (data->nodes == NULL || data->nnodes + 1 >= data->nodessize) |
208 { | 210 { |
209 data->nodessize += 16; | 211 data->nodessize += 16; |
210 if ((data->nodes = th_realloc(data->nodes, | 212 if ((data->nodes = th_realloc(data->nodes, |
728 { | 730 { |
729 for (size_t nnode = 0; nnode < expr->nnodes; nnode++) | 731 for (size_t nnode = 0; nnode < expr->nnodes; nnode++) |
730 { | 732 { |
731 th_regex_node_t *node = &expr->nodes[nnode]; | 733 th_regex_node_t *node = &expr->nodes[nnode]; |
732 | 734 |
735 th_free(node->match.str); | |
733 th_regex_free(node->match.expr); | 736 th_regex_free(node->match.expr); |
734 th_regex_list_free(&node->match.list); | 737 th_regex_list_free(&node->match.list); |
735 } | 738 } |
736 | 739 |
737 th_free(expr->nodes); | 740 th_free(expr->nodes); |