Fix 2 memory leak
This commit is contained in:
parent
9acb0cb16c
commit
e077819626
@ -681,7 +681,11 @@ static int get_all_headers (int fd, hashmap_t hashofheaders)
|
||||
/*
|
||||
* Append the new line to the current header field.
|
||||
*/
|
||||
if( NULL == header ) {
|
||||
tmp = (char *) safemalloc (len + linelen);
|
||||
} else {
|
||||
tmp = (char *) saferealloc (header, len + linelen);
|
||||
}
|
||||
if (tmp == NULL) {
|
||||
safefree (header);
|
||||
safefree (line);
|
||||
|
@ -38,6 +38,7 @@
|
||||
static int build_url (char **url, const char *host, int port, const char *path)
|
||||
{
|
||||
int len;
|
||||
char *tmp;
|
||||
|
||||
assert (url != NULL);
|
||||
assert (host != NULL);
|
||||
@ -45,9 +46,12 @@ static int build_url (char **url, const char *host, int port, const char *path)
|
||||
assert (path != NULL);
|
||||
|
||||
len = strlen (host) + strlen (path) + 14;
|
||||
*url = (char *) safemalloc (len);
|
||||
if (*url == NULL)
|
||||
|
||||
tmp = (char *) saferealloc (*url, len);
|
||||
if (tmp == NULL) {
|
||||
return -1;
|
||||
}
|
||||
*url = tmp;
|
||||
|
||||
return snprintf (*url, len, "http://%s:%d%s", host, port, path);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user