Fix unaligned access in LoadStringFromGzip.

The code in LoadStringFromGzip was attempting to perform an unaligned
access using memcpy, but it cast the source to a pointer with
alignment requirements larger than 1, which, under optimizations,
reintroduced the original issue.
pull/339/head
whitequark 2018-07-18 15:36:59 +00:00
parent efc3da4579
commit 02ec64ee66
1 changed files with 1 additions and 1 deletions

View File

@ -45,7 +45,7 @@ std::string LoadStringFromGzip(const std::string &name) {
// *(uint32_t *) may perform an unaligned access, so do a memcpy. // *(uint32_t *) may perform an unaligned access, so do a memcpy.
uint32_t inflatedSize; uint32_t inflatedSize;
memcpy(&inflatedSize, (uint32_t *)((uintptr_t)data + deflatedSize - 4), sizeof(uint32_t)); memcpy(&inflatedSize, (uint8_t *)((uintptr_t)data + deflatedSize - 4), sizeof(uint32_t));
result.resize(inflatedSize); result.resize(inflatedSize);
stream.next_in = (Bytef *)data; stream.next_in = (Bytef *)data;