Module Name: src
Committed By: rin
Date: Sun Nov 19 12:13:14 UTC 2017
Modified Files:
src/external/bsd/tre/dist/lib: tre-compile.c tre-parse.c
Log Message:
Fix allocation size with wrong use of sizeof, taken from musl libc:
https://git.musl-libc.org/cgit/musl/commit/src/regex/regcomp.c?id=1e81fa4524ecfd51e6a6578ff8038b4c05393101
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/tre/dist/lib/tre-compile.c \
src/external/bsd/tre/dist/lib/tre-parse.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/tre/dist/lib/tre-compile.c
diff -u src/external/bsd/tre/dist/lib/tre-compile.c:1.4 src/external/bsd/tre/dist/lib/tre-compile.c:1.5
--- src/external/bsd/tre/dist/lib/tre-compile.c:1.4 Fri Nov 17 16:16:19 2017
+++ src/external/bsd/tre/dist/lib/tre-compile.c Sun Nov 19 12:13:14 2017
@@ -1949,7 +1949,7 @@ tre_compile(regex_t *preg, const tre_cha
sizeof(*tag_directions) * (tnfa->num_tags + 1));
}
tnfa->minimal_tags = xcalloc((unsigned)tnfa->num_tags * 2 + 1,
- sizeof(tnfa->minimal_tags));
+ sizeof(*tnfa->minimal_tags));
if (tnfa->minimal_tags == NULL)
ERROR_EXIT(REG_ESPACE);
Index: src/external/bsd/tre/dist/lib/tre-parse.c
diff -u src/external/bsd/tre/dist/lib/tre-parse.c:1.4 src/external/bsd/tre/dist/lib/tre-parse.c:1.5
--- src/external/bsd/tre/dist/lib/tre-parse.c:1.4 Fri Nov 17 16:14:30 2017
+++ src/external/bsd/tre/dist/lib/tre-parse.c Sun Nov 19 12:13:14 2017
@@ -108,7 +108,7 @@ tre_new_item(tre_mem_t mem, int min, int
if (*max_i > 1024)
return REG_ESPACE;
*max_i *= 2;
- new_items = xrealloc(array, sizeof(*items) * *max_i);
+ new_items = xrealloc(array, sizeof(*array) * *max_i);
if (new_items == NULL)
return REG_ESPACE;
*items = array = new_items;
@@ -509,7 +509,7 @@ tre_parse_bracket(tre_parse_ctx_t *ctx,
if (num_neg_classes > 0)
{
l->neg_classes = tre_mem_alloc(ctx->mem,
- (sizeof(l->neg_classes)
+ (sizeof(*l->neg_classes)
* (num_neg_classes + 1)));
if (l->neg_classes == NULL)
{
@@ -550,7 +550,7 @@ tre_parse_bracket(tre_parse_ctx_t *ctx,
if (num_neg_classes > 0)
{
l->neg_classes = tre_mem_alloc(ctx->mem,
- (sizeof(l->neg_classes)
+ (sizeof(*l->neg_classes)
* (num_neg_classes + 1)));
if (l->neg_classes == NULL)
{