This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gettext should not modify errno


The gettext() function is documented as preserving the errno value. But
this is not always the case: in dcigettext.c some calls to malloc() and
free() [which can call brk(), mmap(), munmap(), which can set errno even
if then malloc() succeeds] are made after restoring the earlier errno
value.

Here is a fix.


2002-09-19  Bruno Haible  <bruno@clisp.org>

	* intl/dcigettext.c (DCIGETTEXT): Restore errno only right before
	returning.

diff -r -c3 glibc-20020910.bak/intl/dcigettext.c glibc-20020910/intl/dcigettext.c
*** glibc-20020910.bak/intl/dcigettext.c	Wed Sep  4 21:07:20 2002
--- glibc-20020910/intl/dcigettext.c	Thu Sep 19 02:57:47 2002
***************
*** 597,603 ****
  	      /* Found the translation of MSGID1 in domain DOMAIN:
  		 starting at RETVAL, RETLEN bytes.  */
  	      FREE_BLOCKS (block_list);
- 	      __set_errno (saved_errno);
  #if defined HAVE_TSEARCH || defined _LIBC
  	      if (foundp == NULL)
  		{
--- 597,602 ----
***************
*** 636,641 ****
--- 635,641 ----
  		  (*foundp)->translation_length = retlen;
  		}
  #endif
+ 	      __set_errno (saved_errno);
  	      /* Now deal with plural.  */
  	      if (plural)
  		retval = plural_lookup (domain, n, retval, retlen);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]