1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Fix memory leak.

This commit is contained in:
Gijs van Tulder 2012-01-28 14:08:52 +01:00 committed by Giuseppe Scrivano
parent 0a8a898fbe
commit 586ade4fb1
3 changed files with 32 additions and 9 deletions

View File

@ -1,3 +1,8 @@
2012-01-27 Gijs van Tulder <gvtulder@gmail.com>
* retr.c (fd_read_body): Fix a memory leak with chunked responses.
* http.c (skip_short_body): Fix the same memory leak.
2012-01-09 Gijs van Tulder <gvtulder@gmail.com>
* init.c: Disable WARC compression if zlib is disabled.

View File

@ -951,9 +951,12 @@ skip_short_body (int fd, wgint contlen, bool chunked)
break;
remaining_chunk_size = strtol (line, &endl, 16);
xfree (line);
if (remaining_chunk_size == 0)
{
fd_read_line (fd);
line = fd_read_line (fd);
xfree_null (line);
break;
}
}
@ -978,8 +981,13 @@ skip_short_body (int fd, wgint contlen, bool chunked)
{
remaining_chunk_size -= ret;
if (remaining_chunk_size == 0)
if (fd_read_line (fd) == NULL)
return false;
{
char *line = fd_read_line (fd);
if (line == NULL)
return false;
else
xfree (line);
}
}
/* Safe even if %.*s bogusly expects terminating \0 because

View File

@ -307,11 +307,16 @@ fd_read_body (int fd, FILE *out, wgint toread, wgint startpos,
}
remaining_chunk_size = strtol (line, &endl, 16);
xfree (line);
if (remaining_chunk_size == 0)
{
ret = 0;
if (fd_read_line (fd) == NULL)
line = fd_read_line (fd);
if (line == NULL)
ret = -1;
else
xfree (line);
break;
}
}
@ -371,11 +376,16 @@ fd_read_body (int fd, FILE *out, wgint toread, wgint startpos,
{
remaining_chunk_size -= ret;
if (remaining_chunk_size == 0)
if (fd_read_line (fd) == NULL)
{
ret = -1;
break;
}
{
char *line = fd_read_line (fd);
if (line == NULL)
{
ret = -1;
break;
}
else
xfree (line);
}
}
}