From 9c3b84f6998862213327398e68fdda4c5a508a6f Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 9 Sep 2007 14:32:21 +0000 Subject: [PATCH] Set errno to ENOMEM when malloc/realloc fails. Needed on mingw. --- ChangeLog | 5 +++++ lib/canonicalize-lgpl.c | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0e3aa02d80..e68568eaf6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-09-09 Bruno Haible + + * lib/canonicalize-lgpl.c (__realpath): Set errno to ENOMEM when + malloc or realloc fails. + 2007-09-09 Bruno Haible * modules/getcwd (Depends-on): Add malloc-posix. diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c index 14dd536dc4..2ed149bcb0 100644 --- a/lib/canonicalize-lgpl.c +++ b/lib/canonicalize-lgpl.c @@ -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; -- 2.30.2