+2026-05-06 Paul Eggert <eggert@cs.ucla.edu>
+
+ regex-tests: minor memory cleanup
+ * tests/test-regex.c (main): No need for regex to be static,
+ and making it auto is more likely to catch memory leaks in
+ debugging platforms. Clean up after its last use.
+ Omit unnecessary setting/freeing of regs that doesn’t test anything.
+
2026-05-06 Bruno Haible <bruno@clisp.org>
pthread-h: Fix compilation error in C++ mode on mingw.
int
main (void)
{
- static struct re_pattern_buffer regex;
+ struct re_pattern_buffer regex;
unsigned char folded_chars[UCHAR_MAX + 1];
const char *s;
struct re_registers regs;
report_error ("%s: %s", pat, s);
else
{
- memset (®s, 0, sizeof regs);
int ret = re_search (®ex, data, sizeof data - 1,
0, sizeof data - 1, NULL);
if (ret != 0 && ret != 21)
report_error ("re_search '%s' on '%s' returned %d",
pat, data, ret);
regfree (®ex);
- free (regs.start);
- free (regs.end);
}
}
memset (®ex, 0, sizeof regex);
static char const pat_badback[] = "0|()0|\\1|0";
s = re_compile_pattern (pat_badback, sizeof pat_badback, ®ex);
- if (!s && re_search (®ex, "x", 1, 0, 1, ®s) != -1)
- s = "mishandled invalid back reference";
+ if (!s)
+ {
+ memset (®s, 0, sizeof regs);
+ if (re_search (®ex, "x", 1, 0, 1, ®s) != -1)
+ s = "mishandled invalid back reference";
+ regfree (®ex);
+ free (regs.start);
+ free (regs.end);
+ }
if (s && !streq (s, "Invalid back reference"))
report_error ("%s: %s", pat_badback, s);