Re: [PATCH 2/2] am: plug FILE * leak in split_mail_conv()
- From
Jeff King <peff@peff.net>
- Date
- May 12, 2016, 08:03 UTC
- Message-ID
- <20160512080331.GA18874@sigill.intra.peff.net>
- In-Reply-To
- <20160512075939.GA31343@dcvr.yhbt.net>
On Thu, May 12, 2016 at 07:59:39AM +0000, Eric Wong wrote:
Show 10 quoted lines
> I think both patches in this series would benefit from capturing > errno before cleanup. `fclose` can call `free`, and `free` could > do any manner of things such as calling `madvise` with a flag > not implemented in the running kernel, or failing an optional > trylock without being fatal. > > There's lots of non-standard malloc implementations out there :) > > So I'm not sure if there's ever a guarantee that a non-error > function call preserves `errno`.
Good point. This came up not too long ago in:
http://article.gmane.org/gmane.comp.version-control.git/286460
I believe POSIX does say that non-error calls should preserve errno, but all the world is not POSIX. And a future POSIX will mandate that `free` should not touch errno, but it's not the future yet (and also, all the world's not POSIX).
-Peff