Fix memory corruption bug in lcscreen::load()
lcscren::load() didn't compute the number of pixels to load correctly. The data has 2 byte header followed by 3 byte pixels, meaning the number of pixels is (size - 2) / 3. But the code assumed 2 byte pixels, causing load loop to trash memory after end of screen memory.
This commit is contained in:
parent
85d00b243e
commit
f65e0b7139
1 changed files with 1 additions and 1 deletions
|
@ -416,7 +416,7 @@ void lcscreen::load(const std::vector<char>& data) throw(std::bad_alloc, std::ru
|
||||||
width = _width;
|
width = _width;
|
||||||
height = _height;
|
height = _height;
|
||||||
pitch = width;
|
pitch = width;
|
||||||
for(size_t i = 0; i < (data.size() - 2) / 2; i++)
|
for(size_t i = 0; i < (data.size() - 2) / 3; i++)
|
||||||
mem[i] = static_cast<uint32_t>(data2[2 + 3 * i]) * 65536 +
|
mem[i] = static_cast<uint32_t>(data2[2 + 3 * i]) * 65536 +
|
||||||
static_cast<uint32_t>(data2[2 + 3 * i + 1]) * 256 +
|
static_cast<uint32_t>(data2[2 + 3 * i + 1]) * 256 +
|
||||||
static_cast<uint32_t>(data2[2 + 3 * i + 2]);
|
static_cast<uint32_t>(data2[2 + 3 * i + 2]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue