mirror of
https://github.com/NoelFB/blah.git
synced 2024-11-25 16:18:57 +08:00
string internal set method has additional safeguard for bad data
This commit is contained in:
parent
10c1c39419
commit
1ee2fbab3d
|
@ -199,6 +199,8 @@ namespace Blah
|
|||
u8 wash;
|
||||
u8 fill;
|
||||
u8 pad;
|
||||
|
||||
Vertex() = default;
|
||||
};
|
||||
|
||||
struct DrawBatch
|
||||
|
|
|
@ -471,12 +471,22 @@ void Str::set(const char* start, const char* end)
|
|||
if (end == nullptr)
|
||||
end = start + strlen(start);
|
||||
|
||||
// make sure it actually contains characters
|
||||
int len = (int)(end - start);
|
||||
if (len <= 0)
|
||||
{
|
||||
clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_length = len;
|
||||
|
||||
// reserve
|
||||
m_length = (int)(end - start);
|
||||
reserve(m_length);
|
||||
|
||||
// copy the data over
|
||||
char* ptr = data();
|
||||
memcpy(ptr, start, m_length);
|
||||
ptr[m_length] = '\0';
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user