]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
netrc: avoid strdup NULL
authorDaniel Stenberg <daniel@haxx.se>
Mon, 12 May 2025 07:21:31 +0000 (09:21 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 12 May 2025 09:02:51 +0000 (11:02 +0200)
Coverity found a code path where this might happen. Avoid it.

Closes #17319

lib/netrc.c

index 4afd2a08461c4941c198e0001226fa20139ad6bb..971e4b81de2236eeacae11bb0382c3af64a6587b 100644 (file)
@@ -268,7 +268,7 @@ static NETRCcode parsenetrc(struct store_netrc *store,
           else {
             our_login = TRUE;
             free(login);
-            login = strdup(tok);
+            login = strdup(tok ? tok : "");
             if(!login) {
               retcode = NETRC_OUT_OF_MEMORY; /* allocation failed */
               goto out;