From e2f26e45f8dbdf02dd2c2f7cc145bcf1e4d65efe 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. --- 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 fcd71764..bd1b8df0 100644 --- a/src/scripting/lua/core.c +++ b/src/scripting/lua/core.c @@ -204,8 +204,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;