mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:07:45 +00:00
LibGfx: Copy into a u32 in LZWDecoder::next_code() instead of casting
This results in unaligned reads sometimes, depending on the layout of the underlying buffer. Caught by UBSAN.
This commit is contained in:
parent
74da0f24f0
commit
480802805f
1 changed files with 3 additions and 2 deletions
|
@ -187,8 +187,9 @@ public:
|
||||||
const u32* addr = (const u32*)&padded_last_bytes;
|
const u32* addr = (const u32*)&padded_last_bytes;
|
||||||
m_current_code = (*addr & mask) >> current_bit_offset;
|
m_current_code = (*addr & mask) >> current_bit_offset;
|
||||||
} else {
|
} else {
|
||||||
const u32* addr = (const u32*)&m_lzw_bytes.at(current_byte_index);
|
u32 tmp_word;
|
||||||
m_current_code = (*addr & mask) >> current_bit_offset;
|
memcpy(&tmp_word, &m_lzw_bytes.at(current_byte_index), sizeof(u32));
|
||||||
|
m_current_code = (tmp_word & mask) >> current_bit_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_current_code > m_code_table.size()) {
|
if (m_current_code > m_code_table.size()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue