mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-28 09:14:58 +01:00
Verify decoded SawyerChunks
This commit is contained in:
committed by
Michał Janiszewski
parent
9ef629a47d
commit
0fe60663bf
@@ -243,16 +243,20 @@ static size_t decode_chunk_rle_with_size(const uint8* src_buffer, uint8* dst_buf
|
||||
|
||||
dst = dst_buffer;
|
||||
|
||||
assert(length > 0);
|
||||
assert(dstSize > 0);
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
rleCodeByte = src_buffer[i];
|
||||
if (rleCodeByte & 128) {
|
||||
i++;
|
||||
count = 257 - rleCodeByte;
|
||||
assert(dst + count <= dst_buffer + dstSize);
|
||||
assert(i < length);
|
||||
memset(dst, src_buffer[i], count);
|
||||
dst = (uint8*)((uintptr_t)dst + count);
|
||||
} else {
|
||||
assert(dst + rleCodeByte + 1 <= dst_buffer + dstSize);
|
||||
assert(i + 1 < length);
|
||||
memcpy(dst, src_buffer + i + 1, rleCodeByte + 1);
|
||||
dst = (uint8*)((uintptr_t)dst + rleCodeByte + 1);
|
||||
i += rleCodeByte + 1;
|
||||
|
||||
Reference in New Issue
Block a user