mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-08 17:42:12 +03:00
mach: strerror must not return NULL (bug 30555)
This follows1d44530a5b
("string: strerror must not return NULL (bug 30555)"): « For strerror, this fixes commit28aff04781
("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. »
This commit is contained in:
@@ -61,11 +61,18 @@ __strerror_l (int errnum, locale_t loc)
|
|||||||
free (tls_internal->strerror_l_buf);
|
free (tls_internal->strerror_l_buf);
|
||||||
if (__asprintf (&tls_internal->strerror_l_buf, "%s%X",
|
if (__asprintf (&tls_internal->strerror_l_buf, "%s%X",
|
||||||
translate ("Error in unknown error system: ", loc),
|
translate ("Error in unknown error system: ", loc),
|
||||||
errnum) == -1)
|
errnum) > 0)
|
||||||
tls_internal->strerror_l_buf = NULL;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
__set_errno (saved_errno);
|
__set_errno (saved_errno);
|
||||||
return tls_internal->strerror_l_buf;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
es = &__mach_error_systems[system];
|
es = &__mach_error_systems[system];
|
||||||
@@ -79,10 +86,15 @@ __strerror_l (int errnum, locale_t loc)
|
|||||||
if (__asprintf (&tls_internal->strerror_l_buf, "%s%s %d",
|
if (__asprintf (&tls_internal->strerror_l_buf, "%s%s %d",
|
||||||
translate ("Unknown error ", loc),
|
translate ("Unknown error ", loc),
|
||||||
translate (es->subsystem[sub].subsys_name, loc),
|
translate (es->subsystem[sub].subsys_name, loc),
|
||||||
errnum) == -1)
|
errnum) > 0)
|
||||||
tls_internal->strerror_l_buf = NULL;
|
err = tls_internal->strerror_l_buf;
|
||||||
|
else
|
||||||
err = tls_internal->strerror_l_buf;
|
{
|
||||||
|
/* The memory was freed above. */
|
||||||
|
tls_internal->strerror_l_buf = NULL;
|
||||||
|
/* Provide a fallback translation. */
|
||||||
|
err = (char *) translate ("Unknown error", loc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
err = (char *) translate (es->subsystem[sub].codes[code], loc);
|
err = (char *) translate (es->subsystem[sub].codes[code], loc);
|
||||||
|
Reference in New Issue
Block a user