Khronos Public Bugzilla
Bug 573 - Incorrect usage dstImage in _ktxUnpackETC leads to AV
Incorrect usage dstImage in _ktxUnpackETC leads to AV
Status: RESOLVED FIXED
Product: KTX
Classification: Unclassified
Component: library
unspecified
All All
: P3 critical
: ---
Assigned To: callow.mark
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-01-10 11:41 PST by Krystian Bigaj
Modified: 2012-01-17 19:18 PST (History)
0 users

See Also:


Attachments
Patch for etcunpack.c to fix this bug (768 bytes, patch)
2012-01-10 11:41 PST, Krystian Bigaj
Details | Diff

Note You need to log in before you can comment on or make changes to 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 callow.mark 2012-01-17 19:18:59 PST
In SVN r16605.