From: Bruno Haible Date: Thu, 18 May 2023 16:01:06 +0000 (+0200) Subject: astrxfrm: Fix use-after-free bug. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=8ad22bffbdfe1842d4b9856231cc596b98fbcc0e;p=gnulib.git astrxfrm: Fix use-after-free bug. * lib/astrxfrm.c (astrxfrm): Don't use memcpy after realloc succeeded. --- diff --git a/ChangeLog b/ChangeLog index 5c931043f6..0e506f60a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2023-05-18 Bruno Haible + + astrxfrm: Fix use-after-free bug. + * lib/astrxfrm.c (astrxfrm): Don't use memcpy after realloc succeeded. + 2023-05-18 Bruno Haible gnulib-tool: Ignore .orig and .rej files under modules/. diff --git a/lib/astrxfrm.c b/lib/astrxfrm.c index 214ebc38b8..845f0a0711 100644 --- a/lib/astrxfrm.c +++ b/lib/astrxfrm.c @@ -155,10 +155,7 @@ astrxfrm (const char *s, char *resultbuf, size_t *lengthp) { char *memory = (char *) realloc (result, length); if (memory != NULL) - { - memcpy (memory, result, length); - result = memory; - } + result = memory; } } }