bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rpl_unlink sets errno to EPERM on malloc failure


From: Bruno Haible
Subject: Re: rpl_unlink sets errno to EPERM on malloc failure
Date: Sun, 22 Mar 2020 02:41:42 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-174-generic; KDE/5.18.0; x86_64; ; )

Paul Eggert wrote:
--- a/lib/unlink.c
+++ b/lib/unlink.c
@@ -65,10 +65,7 @@ rpl_unlink (char const *name)
           /* Trailing NUL will overwrite the trailing slash.  */
           char *short_name = malloc (len);
           if (!short_name)
-            {
-              errno = EPERM;
-              return -1;
-            }
+            return -1;
           memcpy (short_name, name, len);
           while (len && ISSLASH (short_name[len - 1]))
             short_name[--len] = '\0';

But while on POSIX systems, malloc() is guaranteed to set errno when it fails,
for native Windows systems we need the 'malloc-posix' module, in order to
guarantee this.


2020-03-21  Bruno Haible  <address@hidden>

        unlink: Ensure errno also on native Windows.
        * modules/unlink (Depends-on): Add malloc-posix.

diff --git a/modules/unlink b/modules/unlink
index 63720aa..5fc84d9 100644
--- a/modules/unlink
+++ b/modules/unlink
@@ -9,6 +9,7 @@ Depends-on:
 unistd
 dosname         [test $REPLACE_UNLINK = 1]
 lstat           [test $REPLACE_UNLINK = 1]
+malloc-posix    [test $REPLACE_UNLINK = 1]
 
 configure.ac:
 gl_FUNC_UNLINK




reply via email to

[Prev in Thread] Current Thread [Next in Thread]