From 13d597c61560d1fcd4082bdb41b4a080b8292785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Thu, 7 May 2026 10:31:53 +0200 Subject: [PATCH 1/2] Fix incorrect xcalloc call We were passing the size of the pointer instead of the size of the pointed-to type, which resulted in allocating twice as much as we actually need on 64-bit platforms. Fixes #135. --- lib/tre-compile.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tre-compile.c b/lib/tre-compile.c index 4f80955..302efae 100644 --- a/lib/tre-compile.c +++ b/lib/tre-compile.c @@ -1510,7 +1510,7 @@ tre_compute_npfl(tre_mem_t mem, tre_stack_t *stack, tre_ast_node_t *tree, if (status != REG_OK) return status; /* Allocate arrays for the tags and parameters. */ - tags = xmalloc(sizeof(int) * (num_tags + 1)); + tags = xmalloc(sizeof(*tags) * (num_tags + 1)); if (!tags) return REG_ESPACE; tags[0] = -1; @@ -1938,8 +1938,8 @@ tre_compile(regex_t *preg, const tre_char_t *regex, size_t n, int cflags) memset(tag_directions, -1, sizeof(*tag_directions) * (tnfa->num_tags + 1)); } - tnfa->minimal_tags = xcalloc((unsigned)tnfa->num_tags * 2 + 1, - sizeof(tnfa->minimal_tags)); + tnfa->minimal_tags = xcalloc(tnfa->num_tags * 2 + 1, + sizeof(*tnfa->minimal_tags)); if (tnfa->minimal_tags == NULL) ERROR_EXIT(REG_ESPACE); From a7c5c24920603203e96bc6dec0067db8d3805283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Thu, 7 May 2026 10:39:40 +0200 Subject: [PATCH 2/2] Fix typo in include guard Fixes #132. --- local_includes/regex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local_includes/regex.h b/local_includes/regex.h index daa15a7..5a29aa9 100644 --- a/local_includes/regex.h +++ b/local_includes/regex.h @@ -10,7 +10,7 @@ */ -#ifndef TRE_REXEX_H +#ifndef TRE_REGEX_H #define TRE_REGEX_H 1 #ifdef USE_LOCAL_TRE_H