Changeset 17843


Ignore:
Timestamp:
Oct 17, 2009 2:08:44 AM (7 years ago)
Author:
rouault
Message:

VRT : prevent stack overflow when reading a VRT referencing itself

Location:
trunk/gdal/frmts/vrt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gdal/frmts/vrt/vrtdataset.h

    r17624 r17843  
    239239class CPL_DLL VRTSourcedRasterBand : public VRTRasterBand
    240240{
    241 
     241    int            bAlreadyInIRasterIO;
     242   
    242243    void           Initialize( int nXSize, int nYSize );
    243244
  • trunk/gdal/frmts/vrt/vrtsourcedrasterband.cpp

    r17332 r17843  
    9595    papoSources = NULL;
    9696    bEqualAreas = FALSE;
     97    bAlreadyInIRasterIO = FALSE;
    9798}
    9899
     
    129130        CPLError( CE_Failure, CPLE_AppDefined,
    130131                  "Writing through VRTSourcedRasterBand is not supported." );
     132        return CE_Failure;
     133    }
     134   
     135    /* When using GDALProxyPoolDataset for sources, the recusion will not be */
     136    /* detected at VRT opening but when doing RasterIO. As the proxy pool will */
     137    /* return the already opened dataset, we can just test a member variable. */
     138    if ( bAlreadyInIRasterIO )
     139    {
     140        CPLError( CE_Failure, CPLE_AppDefined,
     141                  "VRTSourcedRasterBand::IRasterIO() called recursively on the same band. "
     142                  "It looks like the VRT is referencing itself." );
    131143        return CE_Failure;
    132144    }
     
    181193            return CE_None;
    182194    }
     195   
     196    bAlreadyInIRasterIO = TRUE;
    183197
    184198/* -------------------------------------------------------------------- */
     
    192206                                            eBufType, nPixelSpace, nLineSpace);
    193207    }
     208   
     209    bAlreadyInIRasterIO = FALSE;
    194210   
    195211    return eErr;
Note: See TracChangeset for help on using the changeset viewer.