apple/Throw: add missing <cstring> header

strlen() and strcpy() are provided by the <string.h> and <cstring>
headers (as functions in global and std namespaces, respectively).

Compilers MAY provide an implementation for either of the functions
without including the extra header but the existence of a declaration
without the header is not assured.
This commit is contained in:
Caleb Xu 2022-05-16 22:31:39 -04:00 committed by Max Kellermann
parent 106ad08cd2
commit c6f7f57776

View File

@ -31,6 +31,7 @@
#include "ErrorRef.hxx"
#include "StringRef.hxx"
#include <cstring>
#include <stdexcept>
namespace Apple {
@ -57,8 +58,8 @@ ThrowOSStatus(OSStatus status, const char *_msg)
const Apple::StringRef cfstr(cferr.CopyDescription());
char msg[1024];
strcpy(msg, _msg);
size_t length = strlen(msg);
std::strcpy(msg, _msg);
size_t length = std::strlen(msg);
cfstr.GetCString(msg + length, sizeof(msg) - length);
throw std::runtime_error(msg);