]> Savannah Git Hosting - gnulib.git/commitdiff
astrxfrm: Fix use-after-free bug.
authorBruno Haible <bruno@clisp.org>
Thu, 18 May 2023 16:01:06 +0000 (18:01 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 20 May 2023 08:58:12 +0000 (10:58 +0200)
* lib/astrxfrm.c (astrxfrm): Don't use memcpy after realloc succeeded.

ChangeLog
lib/astrxfrm.c

index 5c931043f6f20dd61a47e23b92103c6e3c08926d..0e506f60a7563d0185d45882461d96d7f1337454 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-05-18  Bruno Haible  <bruno@clisp.org>
+
+       astrxfrm: Fix use-after-free bug.
+       * lib/astrxfrm.c (astrxfrm): Don't use memcpy after realloc succeeded.
+
 2023-05-18  Bruno Haible  <bruno@clisp.org>
 
        gnulib-tool: Ignore .orig and .rej files under modules/.
index 214ebc38b8758efeae4ec7ddc3c071a8d658130d..845f0a071127e64cc35d533395a4f02f9479c4e1 100644 (file)
@@ -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;
             }
         }
     }