From: Junio C Hamano Date: Thu, 04 Apr 2024 23:08:19 GMT Subject: Re: free and errno, was Re: [PATCH] apply: replace mksnpath() with a mkpathdup() call Message-ID: In-Reply-To: <20240404225313.GA2512966@coredump.intra.peff.net> Jeff King 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 ;-)