Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dds file buffer overrun #1143

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/w3d/renderer/ddsfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,10 @@ bool DDSFileClass::Get_4x4_Block(uint8_t *dst_ptr,
// Gen and ZH only handle DXT1 and DXT5
switch (m_format) {
case WW3D_FORMAT_DXT1: {
int offset = (src_x / 4) * 8 + ((src_y / 4) * (Get_Width(level) / 4));
int offset = (src_x / 4) + ((src_y / 4) * (Get_Width(level) / 4));
unsigned dst_pixel = 0;
uint8_t *block_mem = &Get_Memory_Pointer(level)[8 * offset];

uint32_t color_a = Decode_Packed_565(block_mem);
uint32_t color_b = Decode_Packed_565(block_mem + 2);
// uint32_t code = Decode_Line_Code(block_mem + 4);
Expand Down Expand Up @@ -479,7 +480,7 @@ bool DDSFileClass::Get_4x4_Block(uint8_t *dst_ptr,
}
return has_alpha;
case WW3D_FORMAT_DXT5: {
int offset = (src_x / 4) * 16 + ((src_y / 4) * (Get_Width(level) / 4));
int offset = (src_x / 4) + ((src_y / 4) * (Get_Width(level) / 4));
unsigned dst_pixel = 0;
uint8_t *block_mem = &Get_Memory_Pointer(level)[16 * offset];

Expand Down
Loading