From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id A7EE938555B6; Mon, 20 Mar 2023 11:58:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A7EE938555B6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1679313519; bh=VmWvA8CwMyffb+5FGK5+TPFA8SXpzPD0GrD/HzthKdQ=; h=From:To:Subject:Date:From; b=WRZ/fW/hLtbXH93K0RE6oKnlcfS7bDSI6qIYRfR0rd9ErirVzElh3l7644Sh85RjJ 9zYmQHGt/DZ7nLboPTVH3Ju5xfZdBj+G7a8cbdcNupHT7pO3TAdcvzyBohE8sGgT22 WOTqsCBzlAIfXQXB+4SDMgAX41Akw1BSvv05enk0= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: regex: fix freeing g->charjump in low memory condition X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: 271292b1fbdc7da7c1ed678836eebe596170e635 X-Git-Newrev: e914374383a72810bb5d20ad8428843d70df50e1 Message-Id: <20230320115839.A7EE938555B6@sourceware.org> Date: Mon, 20 Mar 2023 11:58:39 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3De914374383a= 72810bb5d20ad8428843d70df50e1 commit e914374383a72810bb5d20ad8428843d70df50e1 Author: Corinna Vinschen AuthorDate: Thu Mar 16 21:52:48 2023 +0100 Commit: Corinna Vinschen CommitDate: Mon Mar 20 12:56:17 2023 +0100 Cygwin: regex: fix freeing g->charjump in low memory condition =20 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(). =20 Signed-off-by: Corinna Vinschen Diff: --- 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 59da896a90a1..418e24a90ad2 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 =3D=3D NULL && g->charjump !=3D NULL) { - free(g->charjump); + free(&g->charjump[CHAR_MIN]); g->charjump =3D NULL; } }