← Commit list

466c06cf70

Filippo Tedeschi
Filippo Tedeschi
2026-09-23
SUCCESS Duration: 432s

Subject

urlapi: return NULL from curl_url_dup() when given a NULL handle

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

docs/libcurl/curl_url_dup.md+2 -1
@@ -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.
lib/urlapi.c+6 -1
@@ -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);
tests/libtest/lib1560.c+3 -0
@@ -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)