HTTP Auth: Squash error path leaks.

This commit is contained in:
Michael Drake 2018-08-15 11:11:54 +01:00
parent 097f8dcde5
commit 9c29935f3c
1 changed files with 4 additions and 0 deletions

View File

@ -146,6 +146,8 @@ static nserror netsurf__unpack_userpass(
username = malloc(1); username = malloc(1);
password = malloc(1); password = malloc(1);
if (username == NULL || password == NULL) { if (username == NULL || password == NULL) {
free(username);
free(password);
return NSERROR_NOMEM; return NSERROR_NOMEM;
} }
username[0] = '\0'; username[0] = '\0';
@ -167,6 +169,8 @@ static nserror netsurf__unpack_userpass(
username = malloc(len + 1); username = malloc(len + 1);
password = malloc(len2 + 1); password = malloc(len2 + 1);
if (username == NULL || password == NULL) { if (username == NULL || password == NULL) {
free(username);
free(password);
return NSERROR_NOMEM; return NSERROR_NOMEM;
} }
memcpy(username, userpass, len); memcpy(username, userpass, len);