free (tls_internal->strerror_l_buf);
if (__asprintf (&tls_internal->strerror_l_buf, "%s%X",
translate ("Error in unknown error system: ", loc),
- errnum) == -1)
- tls_internal->strerror_l_buf = NULL;
+ 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);
+ }
__set_errno (saved_errno);
- return tls_internal->strerror_l_buf;
+ return err;
}
es = &__mach_error_systems[system];
if (__asprintf (&tls_internal->strerror_l_buf, "%s%s %d",
translate ("Unknown error ", loc),
translate (es->subsystem[sub].subsys_name, loc),
- errnum) == -1)
- tls_internal->strerror_l_buf = NULL;
-
- err = tls_internal->strerror_l_buf;
+ 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 (es->subsystem[sub].codes[code], loc);