PR 67414 Handle newlocale failure

2015-09-02  Janne Blomqvist  <jb@gcc.gnu.org>

	PR libfortran/67414
	* runtime/error.c (gf_strerror): Handle newlocale() failure.

From-SVN: r227406
This commit is contained in:
Janne Blomqvist 2015-09-02 18:13:35 +03:00
parent e4770825f9
commit 51926fab48
2 changed files with 15 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2015-09-02 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/67414
* runtime/error.c (gf_strerror): Handle newlocale() failure.
2015-08-28 James Greenhalgh <james.greenhalgh@arm.com>
* configure.ac: Define HAVE_FTRUNCATE for ARM/AArch64/SH newlib

View File

@ -221,8 +221,16 @@ gf_strerror (int errnum,
#ifdef HAVE_STRERROR_L
locale_t myloc = newlocale (LC_CTYPE_MASK | LC_MESSAGES_MASK, "",
(locale_t) 0);
char *p = strerror_l (errnum, myloc);
freelocale (myloc);
char *p;
if (myloc)
{
p = strerror_l (errnum, myloc);
freelocale (myloc);
}
else
/* newlocale might fail e.g. due to running out of memory, fall
back to the simpler strerror. */
p = strerror (errnum);
return p;
#elif defined(HAVE_STRERROR_R)
#ifdef HAVE_USELOCALE