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 0e3aa02d804f6f0c2ed25079965e6fec011c8817..e68568eaf6faf94c336b15ac783c5553062316db 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+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.
index 14dd536dc469dd9deb2d3125b56a3e735eaa1380..2ed149bcb0ac9fbb641ed8a8fb59aa18a8f856ce 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;