From 1629006348e1f66f07ce3ddcf3ebd2d14556cfce Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 9 Jun 2010 15:30:40 +0200 Subject: [PATCH] Avoid relocwrapper link errors due to gnulib replacement functions. --- ChangeLog | 8 ++++++++ lib/areadlink.c | 20 ++++++++++++++++---- modules/areadlink | 1 - 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index d8cafae3ba..57d9e2c981 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-06-09 Bruno Haible + + Avoid relocwrapper link errors due to gnulib replacement functions. + * lib/areadlink.c: Use the system's malloc, realloc functions. + (areadlink): Set errno to ENOMEM explicitly. + * modules/areadlink (Depends-on): Remove malloc-posix. + Reported by Ben Pfaff . + 2010-06-09 Bruno Haible Avoid relocwrapper link errors due to gnulib replacement functions. diff --git a/lib/areadlink.c b/lib/areadlink.c index b0db4200cb..1c82c55d25 100644 --- a/lib/areadlink.c +++ b/lib/areadlink.c @@ -35,6 +35,10 @@ # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) #endif +/* Use the system functions, not the gnulib overrides in this file. */ +#undef malloc +#undef realloc + /* The initial buffer size for the link value. A power of 2 detects arithmetic overflow earlier, but is not required. */ enum { @@ -85,8 +89,12 @@ areadlink (char const *filename) { buffer = (char *) malloc (link_length); if (buffer == NULL) - /* errno is ENOMEM. */ - return NULL; + { + /* It's easier to set errno to ENOMEM than to rely on the + 'malloc-posix' gnulib module. */ + errno = ENOMEM; + return NULL; + } memcpy (buffer, initial_buf, link_length); } else @@ -113,7 +121,11 @@ areadlink (char const *filename) } buffer = (char *) malloc (buf_size); if (buffer == NULL) - /* errno is ENOMEM. */ - return NULL; + { + /* It's easier to set errno to ENOMEM than to rely on the + 'malloc-posix' gnulib module. */ + errno = ENOMEM; + return NULL; + } } } diff --git a/modules/areadlink b/modules/areadlink index 199c77fa2f..316626994f 100644 --- a/modules/areadlink +++ b/modules/areadlink @@ -6,7 +6,6 @@ lib/areadlink.h lib/areadlink.c Depends-on: -malloc-posix readlink ssize_t stdint -- 2.30.2