]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
wcsdup: Make POSIX compliant.
authorBruno Haible <bruno@clisp.org>
Wed, 19 Nov 2025 11:05:00 +0000 (12:05 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 19 Nov 2025 11:05:00 +0000 (12:05 +0100)
* lib/wcsdup.c: Include <errno.h>.
* lib/wcsdup-impl.h (wcsdup): Set errno before returning NULL.

ChangeLog
lib/wcsdup-impl.h
lib/wcsdup.c

index 220ce6e18c1129e936f4902ec4f409e712410eba..1ee42a2ada3e3e877e224c40581da1881712e6ae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-11-19  Bruno Haible  <bruno@clisp.org>
+
+       wcsdup: Make POSIX compliant.
+       * lib/wcsdup.c: Include <errno.h>.
+       * lib/wcsdup-impl.h (wcsdup): Set errno before returning NULL.
+
 2025-11-18  Paul Eggert  <eggert@cs.ucla.edu>
 
        intprops: port better to Clang < 21
index 4f53ebda18ac8991cd69904668dff8a6229b7e61..b16d86bd16bb852077fa898f6deb3a7d03aa2e43 100644 (file)
@@ -23,7 +23,8 @@ wcsdup (const wchar_t *s)
   if (copy != NULL)
     return wmemcpy (copy, s, n);
   else
-    /* The glibc documentation does not say that errno should be set to ENOMEM
-       here.  */
-    return NULL;
+    {
+      errno = ENOMEM;
+      return NULL;
+    }
 }
index 54f148c1542c24f647aa00ea8409fc27b329b7f4..7ff9dcf2375cd843b5aed2933c610a19dbf68c6c 100644 (file)
@@ -20,6 +20,7 @@
 /* Specification.  */
 #include <wchar.h>
 
+#include <errno.h>
 #include <stdlib.h>
 
 #include "wcsdup-impl.h"