From e914374383a72810bb5d20ad8428843d70df50e1 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 16 Mar 2023 21:52:48 +0100 Subject: [PATCH] Cygwin: regex: fix freeing g->charjump in low memory condition computejumps() moves g->charjump to a position relativ to the value of CHAR_MIN. As such, g->charjump doesn't necessarily point to the address actually allocated. While regfree() takes that into account, the low memory handling in regcomp_internal() doesn't. Fix that by free'ing the actually allocated address, as in regfree(). Signed-off-by: Corinna Vinschen --- winsup/cygwin/regex/regcomp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winsup/cygwin/regex/regcomp.c b/winsup/cygwin/regex/regcomp.c index 59da896a9..418e24a90 100644 --- a/winsup/cygwin/regex/regcomp.c +++ b/winsup/cygwin/regex/regcomp.c @@ -336,7 +336,7 @@ regcomp_internal(regex_t * __restrict preg, computejumps(p, g); computematchjumps(p, g); if(g->matchjump == NULL && g->charjump != NULL) { - free(g->charjump); + free(&g->charjump[CHAR_MIN]); g->charjump = NULL; } }