Skip to content

EnergyTransport.cpp out of bounds memory read #76

@mdunphy

Description

@mdunphy

Code here: https://github.com/CSHS-CWRA/RavenHydroFramework/blob/main/src/EnergyTransport.cpp#L802-L830

At line 802 we allocate hin_hist with length N=_nMinHist[p]

At 821, k runs from 0 to N-1, and at 825 m runs from 1 to N-1, but at lines 828-830 we index hin_hist at indices m-1,m and m+1, and corresponding to N-2, N-1 and N on the last loop iteration. The last one (m=N) is out of bounds, so inside of FunkyTemperatureIntegral, h3 is an undefined value

I suppose the fix is to run the m loop up to N-2 (m<=k becomes m<k), but I am not certain

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions