mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:37:36 +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;
|
||||
m_current_code = (*addr & mask) >> current_bit_offset;
|
||||
} else {
|
||||
const u32* addr = (const u32*)&m_lzw_bytes.at(current_byte_index);
|
||||
m_current_code = (*addr & mask) >> current_bit_offset;
|
||||
u32 tmp_word;
|
||||
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()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue