netrc: Return the correct error code when out of memory #4036
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Prior to this change
Curl_parsenetrc()
would return 27 if thestrdup()
ofpwdir
failed even though a) the function is declared to return anint
andCURLE_OUT_OF_MEMORY
is anenum
, and b) the description in the header file is the function "returns -1 on failure, 0 if the host is found, 1 is the host isn't found"The knock on effect is that libcurl would attempt to info "Couldn't find host www.example.com in the .netrc file; using defaults" and continue running rather than erroring with a
CURLE_OUT_OF_MEMORY
code straight away.However, the chances that curl or any application developed with libcurl continuing after a memory allocation failure is very low and would presumably return the correct error code on the next allocation failure.