IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 31, 2016, 6:29:20 AM (10 years ago)
Author:
eugene
Message:

fix possible double-free in overscan subtraction (scalar case)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/detrend/pmOverscan.c

    r38232 r39499  
    228228        psMetadataAddF32(hdu->header, PS_LIST_TAIL, "OVER_SIG", PS_META_REPLACE, "Overscan stdev", NAN);
    229229
     230        // NOTE psBinaryOp frees arg2 if it is a scalar
    230231        (void)psBinaryOp(input->image, input->image, "-", psScalarAlloc((float)overscanOpts->value, PS_TYPE_F32));
    231232
     
    296297
    297298        psScalar *reducedScalar = psScalarAlloc(reduced, PS_TYPE_F32);
    298         (void)psBinaryOp (image, image, "-", reducedScalar);
     299        psBinaryOp (image, image, "-", psMemIncrRefCounter(reducedScalar)); // NOTE: psBinaryOp frees arg2 if it a scalar, so we need to bump to re-use
    299300
    300301        // subtract the measured value from each overscan region as well
     
    302303        overscan = NULL;   // Overscan image from iterator
    303304        while ((overscan = psListGetAndIncrement(iter))) {
    304           (void)psBinaryOp(overscan, overscan, "-", reducedScalar);
     305          psBinaryOp(overscan, overscan, "-", psMemIncrRefCounter(reducedScalar)); // NOTE: psBinaryOp frees arg2 if it a scalar, so we need to bump to re-use
    305306        }
    306307        psFree(iter);
Note: See TracChangeset for help on using the changeset viewer.