]> 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 09:01:56 +0000 (11:01 +0200)
* lib/astrxfrm.c (astrxfrm): Don't use memcpy after realloc succeeded.

ChangeLog
lib/astrxfrm.c

index 54397e13771c5c087ad191c8652598c7b665776f..b9a3ef10b3728f7e70d54858aad4c3b35c31abb1 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 a9aae31f438c986c5af89464de549bad1ace7c71..845f0a071127e64cc35d533395a4f02f9479c4e1 100644 (file)
@@ -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 <bruno@clisp.org>, 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;
             }
         }
     }