mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
Clamp string reads to buffer size
This commit is contained in:
parent
dc18a1261c
commit
df42100320
|
@ -162,9 +162,11 @@ private:
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
std::string output(length, '\0');
|
const auto length_to_read = std::min(length, data.size() - offset);
|
||||||
std::memcpy(output.data(), data.data() + offset, length);
|
|
||||||
offset += length;
|
std::string output(length_to_read, '\0');
|
||||||
|
std::memcpy(output.data(), data.data() + offset, length_to_read);
|
||||||
|
offset += length_to_read;
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue