提交 1e81fa45 编写于 作者: S Szabolcs Nagy

fix allocation sizes in regcomp

sizeof had incorrect argument in a few places, the size was always
large enough so the issue was not critical.
上级 c3a43b35
...@@ -516,7 +516,7 @@ tre_new_item(tre_mem_t mem, int min, int max, int *i, int *max_i, ...@@ -516,7 +516,7 @@ tre_new_item(tre_mem_t mem, int min, int max, int *i, int *max_i,
if (*max_i > 1024) if (*max_i > 1024)
return REG_ESPACE; return REG_ESPACE;
*max_i *= 2; *max_i *= 2;
new_items = xrealloc(array, sizeof(*items) * *max_i); new_items = xrealloc(array, sizeof(*array) * *max_i);
if (new_items == NULL) if (new_items == NULL)
return REG_ESPACE; return REG_ESPACE;
*items = array = new_items; *items = array = new_items;
...@@ -765,7 +765,7 @@ tre_parse_bracket(tre_parse_ctx_t *ctx, tre_ast_node_t **result) ...@@ -765,7 +765,7 @@ tre_parse_bracket(tre_parse_ctx_t *ctx, tre_ast_node_t **result)
if (num_neg_classes > 0) if (num_neg_classes > 0)
{ {
l->neg_classes = tre_mem_alloc(ctx->mem, l->neg_classes = tre_mem_alloc(ctx->mem,
(sizeof(l->neg_classes) (sizeof(*l->neg_classes)
* (num_neg_classes + 1))); * (num_neg_classes + 1)));
if (l->neg_classes == NULL) if (l->neg_classes == NULL)
{ {
...@@ -805,7 +805,7 @@ tre_parse_bracket(tre_parse_ctx_t *ctx, tre_ast_node_t **result) ...@@ -805,7 +805,7 @@ tre_parse_bracket(tre_parse_ctx_t *ctx, tre_ast_node_t **result)
if (num_neg_classes > 0) if (num_neg_classes > 0)
{ {
l->neg_classes = tre_mem_alloc(ctx->mem, l->neg_classes = tre_mem_alloc(ctx->mem,
(sizeof(l->neg_classes) (sizeof(*l->neg_classes)
* (num_neg_classes + 1))); * (num_neg_classes + 1)));
if (l->neg_classes == NULL) if (l->neg_classes == NULL)
{ {
...@@ -3167,7 +3167,7 @@ regcomp(regex_t *restrict preg, const char *restrict regex, int cflags) ...@@ -3167,7 +3167,7 @@ regcomp(regex_t *restrict preg, const char *restrict regex, int cflags)
sizeof(*tag_directions) * (tnfa->num_tags + 1)); sizeof(*tag_directions) * (tnfa->num_tags + 1));
} }
tnfa->minimal_tags = xcalloc((unsigned)tnfa->num_tags * 2 + 1, tnfa->minimal_tags = xcalloc((unsigned)tnfa->num_tags * 2 + 1,
sizeof(tnfa->minimal_tags)); sizeof(*tnfa->minimal_tags));
if (tnfa->minimal_tags == NULL) if (tnfa->minimal_tags == NULL)
ERROR_EXIT(REG_ESPACE); ERROR_EXIT(REG_ESPACE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册