summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2011-08-20 18:30:28 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2011-08-20 18:30:28 +0200
commit35b2f0e44af1544253e0d1d5edaf5afe6d879f97 (patch)
tree75386860c59202494a9965fadc8c8483ac4fc89a
parentf4094214ebc8ef7c5e8140605bc17907b5672b13 (diff)
Fix localhost() after memory failure
* libshouldbeinlibc/localhost.c (localhost): Free and reset buf when reallocation failed.
-rw-r--r--libshouldbeinlibc/localhost.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libshouldbeinlibc/localhost.c b/libshouldbeinlibc/localhost.c
index f21f970d..f0225116 100644
--- a/libshouldbeinlibc/localhost.c
+++ b/libshouldbeinlibc/localhost.c
@@ -44,6 +44,8 @@ localhost ()
new = realloc (buf, buf_len);
if (! new)
{
+ free (buf);
+ buf = 0;
errno = ENOMEM;
return 0;
}