1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00

Improve fs::container_stream::write (#9976)

Add overflow condition.
This commit is contained in:
Eladash 2021-03-16 13:03:58 +02:00 committed by GitHub
parent f8e9ea45ba
commit 4c7fc8a70a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -696,13 +696,16 @@ namespace fs
{ {
const u64 old_size = obj.size(); const u64 old_size = obj.size();
if (old_size + size < old_size) if (old_size + size < old_size || pos + size < pos)
{ {
xovfl(); xovfl();
} }
if (pos > old_size) if (pos > old_size)
{ {
// Reserve memory
obj.reserve(pos + size);
// Fill gap if necessary (default-initialized) // Fill gap if necessary (default-initialized)
obj.resize(pos); obj.resize(pos);
} }