Khronos Public Bugzilla

Bug 573

Summary: Incorrect usage dstImage in _ktxUnpackETC leads to AV
Product: KTX Reporter: Krystian Bigaj <krystian.bigaj>
Component: libraryAssignee: Mark Callow <khronos>
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: Patch for etcunpack.c to fix this bug

Description Krystian Bigaj 2012-01-10 11:41:02 PST
Created attachment 92 [details]
Patch for etcunpack.c to fix this bug

In function _ktxUnpackETC (etcunpack.c) there is:

...
newimg[ (yy*active_width)*3 + xx*3 + 0 ] = *dstImage[ (yy*width)*3 + xx*3 + 0];
newimg[ (yy*active_width)*3 + xx*3 + 1 ] = *dstImage[ (yy*width)*3 + xx*3 + 1];
newimg[ (yy*active_width)*3 + xx*3 + 2 ] = *dstImage[ (yy*width)*3 + xx*3 + 2];
...

but it must be of course like this:

...
newimg[ (yy*active_width)*3 + xx*3 + 0 ] = (*dstImage)[ (yy*width)*3 + xx*3 + 0];
newimg[ (yy*active_width)*3 + xx*3 + 1 ] = (*dstImage)[ (yy*width)*3 + xx*3 + 1];
newimg[ (yy*active_width)*3 + xx*3 + 2 ] = (*dstImage)[ (yy*width)*3 + xx*3 + 2];
...

Without this (typo?) fix you get an AV or "garbage" image.

PS. This code also is not optimized, but case when this code would be executed is really rare/low.
Comment 1 Mark Callow 2012-01-17 19:18:59 PST
In SVN r16605.