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=c9fbf0c1433846232e49d6712e34134d6845cf00;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 54397e1377..b9a3ef10b3 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 a9aae31f43..845f0a0711 100644 --- a/lib/astrxfrm.c +++ b/lib/astrxfrm.c @@ -1,5 +1,5 @@ /* Locale dependent string transformation for comparison. - Copyright (C) 2010-2022 Free Software Foundation, Inc. + Copyright (C) 2010-2023 Free Software Foundation, Inc. Written by Bruno Haible , 2010. This program is free software: you can redistribute it and/or modify it @@ -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; } } }