GPUOpen-Tools / compressonator

Tool suite for Texture and 3D Model Compression, Optimization and Analysis using CPUs, GPUs and APUs
1.29k stars 194 forks source link

Fixed destination pointer calculation when converting from RGBA to RGB #248

Closed cyrilcourvoisier closed 1 year ago

cyrilcourvoisier commented 1 year ago

I have fixed an error in CCodecBuffer_RGB888::WriteBlockRGBA function: Instead of using nChannelCount value (which is 3 for RGB texels), it uses the size of nChannelCount variable(which is 4 for most modern systems). It causes buffer overflow as the pointer goes after the buffer limits in addition to writing to the wrong location.

NPCompress commented 1 year ago

@cyrilcourvoisier Thank you for your pull contributions, they will be reviewed and merged soon.

denislevesqueAMD commented 1 year ago

@cyrilcourvoisier This is a good fix, but it is not thorough enough to actually fix the entire problem with the CCodecBuffer_RGB888 class. Even just in the file you changed there are multiple instances of sizeof(nChannelCount) that you didn't update.

The fix has been made in the development branch and will be part of the next release.