Prevent String::Set from crashing if passed a nullptr

This commit is contained in:
Tim Wojtulewicz 2020-10-14 12:37:32 -07:00
parent ecd970ffde
commit b1e517e863

View file

@ -132,12 +132,15 @@ void String::Set(const char* str)
{ {
Reset(); Reset();
if ( str )
{
n = strlen(str); n = strlen(str);
b = new u_char[n+1]; b = new u_char[n+1];
memcpy(b, str, n+1); memcpy(b, str, n+1);
final_NUL = true; final_NUL = true;
use_free_to_delete = false; use_free_to_delete = false;
} }
}
void String::Set(const std::string& str) void String::Set(const std::string& str)
{ {