SpartanJ / SOIL2

SOIL2 is a tiny C library used primarily for uploading textures into OpenGL.
MIT No Attribution
370 stars 75 forks source link

Semantic Error in SOIL_internal_create_OGL_texture function #15

Closed SpartanJ closed 8 years ago

SpartanJ commented 8 years ago

Original report by subdivider (Bitbucket: subdivider, GitHub: subdivider).


Hello, the section of code on lines (1578 - 1591) have semantic error:

#!c
unsigned char *resampled;
int reduce_block_x = 1, reduce_block_y = 1;
int new_width, new_height;
if( iwidth > max_supported_size )
{
    reduce_block_x = iwidth / max_supported_size;
}
if( iheight > max_supported_size )
{
    reduce_block_y = iheight / max_supported_size;
}
new_width = iwidth / reduce_block_x;
new_height = iheight / reduce_block_y;
resampled = (unsigned char*)malloc( channels*new_width*new_height );

let's say

  1. iwidth = 1.25 max_supported_size*
  2. reduce_block_x = 1
  3. new_width = iwidth

So resampled image's new_width will be still greater than max_supported_size. Same applies to new_height if iheight > max_supported_size ...

SpartanJ commented 8 years ago

Original comment by subdivider (Bitbucket: subdivider, GitHub: subdivider).


Sorry I'm wrong, before that code section You have changed iwidth and iheight to power of two numbers... So everything is OK...