urlapi: return NULL from curl_url_dup() when given a NULL handle
No binary (build failed)
—
(log yok)
| @@ -56,4 +56,5 @@ int main(void) | |
| # RETURN VALUE | |
| - | Returns a pointer to a new `CURLU` handle or NULL if out of memory. |
| + | Returns a pointer to a new `CURLU` handle or NULL if out of memory or if |
| + | *inhandle* is NULL. |
| @@ -1433,7 +1433,12 @@ void curl_url_cleanup(CURLU *u) | |
| CURLU *curl_url_dup(const CURLU *in) | |
| { | |
| - | struct Curl_URL *u = curlx_calloc(1, sizeof(struct Curl_URL)); |
| + | struct Curl_URL *u; |
| + | |
| + | if(!in) |
| + | return NULL; |
| + | |
| + | u = curlx_calloc(1, sizeof(struct Curl_URL)); |
| if(u) { | |
| DUP(u, in, scheme); | |
| DUP(u, in, user); | |
| @@ -2423,6 +2423,9 @@ static int test_api_errors(void) | |
| if(rc != CURLUE_BAD_HANDLE) | |
| return 1; | |
| + | if(curl_url_dup(NULL)) |
| + | return 4; |
| + | |
| /* NULL part pointer */ | |
| rc = curl_url_get(u, CURLUPART_URL, NULL, 0); | |
| if(rc != CURLUE_BAD_PARTPOINTER) | |