Date: Fri, 11 May 2012 21:56:24 +0400 From: Andrey Chernov <ache@FreeBSD.ORG> To: Konstantin Belousov <kostikbel@gmail.com> Cc: svn-src-head@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, src-committers@FreeBSD.ORG, Konstantin Belousov <kib@FreeBSD.ORG> Subject: Re: svn commit: r235266 - head/lib/libc/stdlib Message-ID: <20120511175624.GA21202@vniz.net> In-Reply-To: <20120511170412.GR2358@deviant.kiev.zoral.com.ua> References: <201205111129.q4BBT85G081093@svn.freebsd.org> <20120511145432.GA19173@vniz.net> <20120511170412.GR2358@deviant.kiev.zoral.com.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
--1yeeQ81UyVL57Vl7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 11, 2012 at 08:04:12PM +0300, Konstantin Belousov wrote: > On Fri, May 11, 2012 at 06:54:32PM +0400, Andrey Chernov wrote: > > Thanks, but in this two places old errno value should be saved across > > free() because free() may damage it: > I do not agree. free() cannot change errno. Perhaps I forget something, so please refer to standard stating that. IEEE Std 1003.1-2008 says that "No errors are defined." in the ERRORS=20 section, but states that beforehand: "if the argument does not match a pointer earlier returned by a function=20 in POSIX.1-2008 that allocates memory as if by malloc(), or if the space ha= s=20 been deallocated by a call to free() or realloc(), the behavior is=20 undefined. Any use of a pointer that refers to freed space results in undefined=20 behavior. =2E.. The DESCRIPTION is updated to clarify that if the pointer returned is not= =20 by a function that allocates memory as if by malloc(), then the behavior=20 is undefined." So that "undefined behavior" case still can modify errno. (Some internal syscalls (like munmap etc) could produce errno. In any=20 case it is very implemetation defined.) --=20 http://ache.vniz.net/ --1yeeQ81UyVL57Vl7 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAk+tUsgACgkQVg5YK5ZEdN0b8gCfUwWDCgWdiU802+IcvPqYY4ku 7ggAoLggsKfmilwvKhvLQBjln3rQhj1H =q0hH -----END PGP SIGNATURE----- --1yeeQ81UyVL57Vl7--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120511175624.GA21202>