mirror of
https://github.com/gcc-mirror/gcc.git
synced 2024-11-21 13:40:47 +00:00
libstdc++: Handle strerror returning null
The linux man page for strerror says that some systems return NULL for an unknown error number. That violates the C and POSIX standards, but we can esily handle it to avoid a segfault. libstdc++-v3/ChangeLog: * src/c++11/system_error.cc (strerror_string): Handle non-conforming NULL return from strerror.
This commit is contained in:
parent
5dd1f0d69f
commit
ee4cc961ce
@ -110,7 +110,11 @@ namespace
|
||||
#else
|
||||
string strerror_string(int err)
|
||||
{
|
||||
return strerror(err); // XXX Not thread-safe.
|
||||
auto str = strerror(err); // XXX Not thread-safe.
|
||||
if (str) [[__likely__]]
|
||||
return str;
|
||||
// strerror should not return NULL, but some implementations do.
|
||||
return "Unknown error";
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user