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

imageConvert from BC3 to RGBA32F with mipmap cause memory writen out of bounds #80

Open
junjie020 opened this issue Jun 20, 2023 · 0 comments
Labels

Comments

@junjie020
Copy link

I have a BC3 format texture with mipmaps, and I want to convert it to RGBA32F format with mipmaps. It will cause memory writen out of bounds (The texture I tested is attached in this issue).

Compile texturec tools, and run this command line:
> texturecDebug -f {yourdir}/test_BC3.dds -o {outputdir}/out_RGBA32F.dds -t RGBA32F -q fastest --mips

It will throw an exception in this code line:
https://github.com/bkaradzic/bimg/blob/master/src/image.cpp#LL4465C32-L4465C32

(The heap is broken right now)

The reason I found in the code:
https://github.com/bkaradzic/bimg/blob/master/src/image.cpp#L1284

The attach file is BC3 format with mipmaps, it's resolution is 8x8. In mip level 2, the resolution should be 2x2, but the lowest block size of BC3 format is 4x4, so imageGetRawData function return m_width and m_height in var mip are 4. But RGBA32F format resolution in mip level 2 must be 2x2, then it will cause memory writen out of bounds.

test_BC3.zip

@bkaradzic bkaradzic added the bug label Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants