Subject: Re: free and errno, was Re: [PATCH] apply: replace mksnpath() with a mkpathdup() call

From: Junio C Hamano <[email-masked]>
Date: Thu, 04 Apr 2024 16:08:19 -0700

Jeff King <[email-masked]> writes:

>> +			free(newpath);
>>  			if (errno != EEXIST)
>>  				break;
>>  			++nr;
>
> At any rate, you can probably see the places where free() clobbering
> errno would be a problem here. Our return when "res < 0" (though I don't
> think any of the callers actually care about errno after that), the
> check for EEXIST at the bottom of the loop, and after we break out of
> the loop, we use error_errno() to report it.

Yeah, a failing free() is unlikely to set errno to EEXIST ;-)