From: Glenn L McGrath Date: Wed, 11 Aug 2004 03:50:30 +0000 (-0000) Subject: Patch from Tito to fix memory leak upon error. X-Git-Tag: 1_00_rc3~12 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=18bbd9bf3b222eb85600f895c9a1f7dcb5f8ccef;p=oweals%2Fbusybox.git Patch from Tito to fix memory leak upon error. --- diff --git a/libbb/xreadlink.c b/libbb/xreadlink.c index 21a657dfc..49823fa7f 100644 --- a/libbb/xreadlink.c +++ b/libbb/xreadlink.c @@ -24,8 +24,9 @@ extern char *xreadlink(const char *path) buf = xrealloc(buf, bufsize += GROWBY); readsize = readlink(path, buf, bufsize); /* 1st try */ if (readsize == -1) { - bb_perror_msg("%s", path); - return NULL; + bb_perror_msg("%s", path); + free(buf); + return NULL; } } while (bufsize < readsize + 1);