netrc: avoid strdup NULL

Coverity found a code path where this might happen. Avoid it.

Closes #17319
This commit is contained in:
Daniel Stenberg 2025-05-12 09:21:31 +02:00
parent 5f6c714d24
commit c5398fa393
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View 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;