Fixed buffer overflow in string handling
pos should never exceed strlen, else the overflow check 'if (!len)' will wrongfully pass
This commit is contained in:
parent
0726c4d4ea
commit
2b7637df36
@ -87,7 +87,7 @@ String::String(const std::string& str, size_t pos, size_t len)
|
||||
: cstr_(0), len_(0)
|
||||
{
|
||||
size_t strlen = str.size();
|
||||
pos = max(pos, strlen);
|
||||
pos = min(pos, strlen);
|
||||
len = min(strlen - pos, len);
|
||||
if (!len) return;
|
||||
memcpy(allocate(len), str.c_str() + pos, len);
|
||||
|
Loading…
x
Reference in New Issue
Block a user