Set errno to ENOMEM when malloc/realloc fails. Needed on mingw.
authorBruno Haible <bruno@clisp.org>
Sun, 9 Sep 2007 14:32:21 +0000 (14:32 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 9 Sep 2007 14:32:21 +0000 (14:32 +0000)
ChangeLog
lib/canonicalize-lgpl.c

index 0e3aa02..e68568e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2007-09-09  Bruno Haible  <bruno@clisp.org>
 
+       * lib/canonicalize-lgpl.c (__realpath): Set errno to ENOMEM when
+       malloc or realloc fails.
+
+2007-09-09  Bruno Haible  <bruno@clisp.org>
+
        * modules/getcwd (Depends-on): Add malloc-posix.
        * modules/glob (Depends-on): Likewise.
        * modules/putenv (Depends-on): Likewise.
index 14dd536..2ed149b 100644 (file)
@@ -135,7 +135,12 @@ __realpath (const char *name, char *resolved)
     {
       rpath = malloc (path_max);
       if (rpath == NULL)
-       return NULL;
+       {
+         /* It's easier to set errno to ENOMEM than to rely on the
+            'malloc-posix' gnulib module.  */
+         errno = ENOMEM;
+         return NULL;
+       }
     }
   else
     rpath = resolved;
@@ -209,7 +214,12 @@ __realpath (const char *name, char *resolved)
                new_size += path_max;
              new_rpath = (char *) realloc (rpath, new_size);
              if (new_rpath == NULL)
-               goto error;
+               {
+                 /* It's easier to set errno to ENOMEM than to rely on the
+                    'realloc-posix' gnulib module.  */
+                 errno = ENOMEM;
+                 goto error;
+               }
              rpath = new_rpath;
              rpath_limit = rpath + new_size;