Changeset 12108

Show
Ignore:
Timestamp:
09/10/07 19:07:53 (1 year ago)
Author:
warmerdam
Message:

fix big color table arrays on stack problem (#1759)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/frmts/gtiff/gt_overview.cpp

    r10645 r12108  
    238238/*      Do we have a palette?  If so, create a TIFF compatible version. */ 
    239239/* -------------------------------------------------------------------- */ 
    240     unsigned short      anTRed[65536], anTGreen[65536], anTBlue[65536]; 
    241240    unsigned short      *panRed=NULL, *panGreen=NULL, *panBlue=NULL; 
    242241 
     
    246245        int nColorCount = MIN(65536,poCT->GetColorEntryCount()); 
    247246 
    248         memset( anTRed, 0, 65536 * 2 ); 
    249         memset( anTGreen, 0, 65536 * 2 ); 
    250         memset( anTBlue, 0, 65536 * 2 ); 
     247        panRed   = (unsigned short *) CPLCalloc(nColorCount,sizeof(unsigned short)); 
     248        panGreen = (unsigned short *) CPLCalloc(nColorCount,sizeof(unsigned short)); 
     249        panBlue  = (unsigned short *) CPLCalloc(nColorCount,sizeof(unsigned short)); 
    251250 
    252251        for( int iColor = 0; iColor < nColorCount; iColor++ ) 
     
    256255            poCT->GetColorEntryAsRGB( iColor, &sRGB ); 
    257256 
    258             anTRed[iColor] = (unsigned short) (256 * sRGB.c1); 
    259             anTGreen[iColor] = (unsigned short) (256 * sRGB.c2); 
    260             anTBlue[iColor] = (unsigned short) (256 * sRGB.c3); 
    261         } 
    262  
    263         panRed = anTRed; 
    264         panGreen = anTGreen; 
    265         panBlue = anTBlue; 
     257            panRed[iColor] = (unsigned short) (256 * sRGB.c1); 
     258            panGreen[iColor] = (unsigned short) (256 * sRGB.c2); 
     259            panBlue[iColor] = (unsigned short) (256 * sRGB.c3); 
     260        } 
    266261    } 
    267262         
     
    288283    } 
    289284 
     285    if (panRed) 
     286    { 
     287        CPLFree(panRed); 
     288        CPLFree(panGreen); 
     289        CPLFree(panBlue); 
     290        panRed = panGreen = panBlue = NULL; 
     291    } 
     292 
    290293    XTIFFClose( hOTIFF ); 
    291294