changeset 9199:178478846e9b

Set errno to ENOMEM when malloc/realloc fails. Needed on mingw.
author Bruno Haible <bruno@clisp.org>
date Sun, 09 Sep 2007 14:32:21 +0000
parents d5ed7e149f08
children da3798e554d6
files ChangeLog lib/canonicalize-lgpl.c
diffstat 2 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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.
--- a/lib/canonicalize-lgpl.c
+++ b/lib/canonicalize-lgpl.c
@@ -135,7 +135,12 @@
     {
       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 @@
 		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;