mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
string: strerror must not return NULL (bug 30555)
For strerror, this fixes commit 28aff04781
("string:
Implement strerror in terms of strerror_l"). This commit avoids
returning NULL for strerror_l as well, although POSIX allows this
behavior for strerror_l.
Reviewed-by: Arjun Shankar <arjun@redhat.com>
This commit is contained in:
@ -43,10 +43,15 @@ __strerror_l (int errnum, locale_t loc)
|
||||
struct tls_internal_t *tls_internal = __glibc_tls_internal ();
|
||||
free (tls_internal->strerror_l_buf);
|
||||
if (__asprintf (&tls_internal->strerror_l_buf, "%s%d",
|
||||
translate ("Unknown error ", loc), errnum) == -1)
|
||||
tls_internal->strerror_l_buf = NULL;
|
||||
|
||||
err = tls_internal->strerror_l_buf;
|
||||
translate ("Unknown error ", loc), errnum) > 0)
|
||||
err = tls_internal->strerror_l_buf;
|
||||
else
|
||||
{
|
||||
/* The memory was freed above. */
|
||||
tls_internal->strerror_l_buf = NULL;
|
||||
/* Provide a fallback translation. */
|
||||
err = (char *) translate ("Unknown error", loc);
|
||||
}
|
||||
}
|
||||
else
|
||||
err = (char *) translate (err, loc);
|
||||
|
Reference in New Issue
Block a user