1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-01-03 14:57:44 -05:00

l_pipe_read: Don't leak the old block if mem_realloc fails.

[ From commit 699663614a in ELinks
  0.12.GIT.  --KON ]
This commit is contained in:
Kalle Olavi Niemitalo 2007-04-19 00:15:30 +03:00 committed by Kalle Olavi Niemitalo
parent 43a1d6f880
commit 711fc8c30a

View File

@ -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;