Opened 8 years ago

Closed 8 years ago

#6201 closed defect (fixed)

vrtderivedrasterband.cpp probable logic errors

Reported by: Kurt Schwehr Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: svn-trunk
Severity: normal Keywords:
Cc: antonio

Description

Haven't yet checked in the change that gets to this point but will in the next day.

Always freeing the same iSource?

    for (iSource = 0; iSource < nSources; iSource++) {
        pBuffers[iSource] = reinterpret_cast<void *>(
            VSIMalloc(sourcesize * nBufXSize * nBufYSize) );
        if (pBuffers[iSource] == NULL)
        {
            for (int i = 0; i < iSource; i++) {
                // TODO: How is this not a bug?
                VSIFree(pBuffers[iSource]);
            }
            CPLFree(pBuffers);

Only catches the error in the last call to RasterIO.

    /* ---- Load values for sources into packed buffers ---- */
    CPLErr eErr = CE_None;
    for(iSource = 0; iSource < nSources; iSource++) {
        // TODO: This does not track if one of the RasterIO calls fails.
        // Only the last.
        eErr = reinterpret_cast<VRTSource *>( papoSources[iSource] )->RasterIO(
            nXOff, nYOff, nXSize, nYSize,
            pBuffers[iSource], nBufXSize, nBufYSize,
            eSrcType, GDALGetDataTypeSize( eSrcType ) / 8,
            (GDALGetDataTypeSize( eSrcType ) / 8) * nBufXSize, &sExtraArg);
    }

    /* ---- Apply pixel function ---- */
    if (eErr == CE_None) {

Change History (2)

comment:1 by antonio, 8 years ago

Cc: antonio added

comment:2 by Even Rouault, 8 years ago

Resolution: fixed
Status: newclosed

trunk r31497 "VRTDerivedRasterBand: fix wrong freeing of working buffers in error code path, and take into account RasterIO errors on source (#6201, reported by goatbar)"

Note: See TracTickets for help on using tickets.