From: Bruno Haible Date: Thu, 18 May 2023 16:01:06 +0000 (+0200) Subject: astrxfrm: Fix use-after-free bug. X-Git-Tag: v1.0~1320 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=f8940f483940ee28c5333a70f20241790b6aa402;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 dedf78c369..f105e2db8f 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; } } }