mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
Prevent String::Set from crashing if passed a nullptr
This commit is contained in:
parent
ecd970ffde
commit
b1e517e863
1 changed files with 8 additions and 5 deletions
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue