From 711fc8c30a4af932000079d3ad385856a471ae7e Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Thu, 19 Apr 2007 00:15:30 +0300 Subject: [PATCH] l_pipe_read: Don't leak the old block if mem_realloc fails. [ From commit 699663614a28ab06ed84e868b3b42ea9e8cae2a0 in ELinks 0.12.GIT. --KON ] --- src/scripting/lua/core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/scripting/lua/core.c b/src/scripting/lua/core.c index c82004222..d72073874 100644 --- a/src/scripting/lua/core.c +++ b/src/scripting/lua/core.c @@ -203,8 +203,10 @@ l_pipe_read(LS) size_t l = fread(buf, 1, sizeof(buf), fp); if (l > 0) { - s = mem_realloc(s, len + l); - if (!s) goto lua_error; + unsigned char *news = mem_realloc(s, len + l); + + if (!news) goto lua_error; + s = news; memcpy(s + len, buf, l); len += l;