http: fix memory leak and potential null pointer argument to strlen

This commit is contained in:
Brad Parker 2019-07-04 16:27:36 -04:00
parent 2c7e7ac083
commit 0ecac5c8ff

View File

@ -288,6 +288,9 @@ struct http_connection_t *net_http_connection_new(const char *url,
else
error = true;
if (string_is_empty(conn->scan))
goto error;
/* Get the port here from the url if it's specified.
does not work on username password urls: user:pass@domain.com
@ -312,6 +315,8 @@ struct http_connection_t *net_http_connection_new(const char *url,
strlcpy(new_domain, domain_port, sizeof(new_domain));
free(url_dup);
if (uri != NULL)
{
if (strchr(uri, (char) '/') == NULL)