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 wash;
|
||||||
u8 fill;
|
u8 fill;
|
||||||
u8 pad;
|
u8 pad;
|
||||||
|
|
||||||
|
Vertex() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DrawBatch
|
struct DrawBatch
|
||||||
|
|
|
@ -471,12 +471,22 @@ void Str::set(const char* start, const char* end)
|
||||||
if (end == nullptr)
|
if (end == nullptr)
|
||||||
end = start + strlen(start);
|
end = start + strlen(start);
|
||||||
|
|
||||||
|
// make sure it actually contains characters
|
||||||
|
int len = (int)(end - start);
|
||||||
|
if (len <= 0)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_length = len;
|
||||||
|
|
||||||
// reserve
|
// reserve
|
||||||
m_length = (int)(end - start);
|
|
||||||
reserve(m_length);
|
reserve(m_length);
|
||||||
|
|
||||||
// copy the data over
|
// copy the data over
|
||||||
char* ptr = data();
|
char* ptr = data();
|
||||||
memcpy(ptr, start, m_length);
|
memcpy(ptr, start, m_length);
|
||||||
ptr[m_length] = '\0';
|
ptr[m_length] = '\0';
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user