Skip to content

BMI GetValue: use actual gridsize in memcpy - #106

Merged
analytophile merged 3 commits into
CSHS-CWRA:mainfrom
robmtud:robmtud/BMI_GetValue_gridsize
Aug 19, 2026
Merged

analytophile merged 3 commits into
CSHS-CWRA:mainfrom
robmtud:robmtud/BMI_GetValue_gridsize

Conversation

@robmtud

@robmtud robmtud commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

This uses CRavenBMI::GetVarNbytes to determine the output buffer size in the memcpy call to write the ouput values.

Previously a call to CModel::GetNumHRUs was used to determine the grid size of the output variable. In the case that the number of HRUs is larger than the number of sub basins this can cause a segmenation fault if GetValue is called with an output buffer allocated for a variable on the sub basin grid.

Additionally the different calls to either CModel::GetNumSubBasins or CModel::GetNumHRUs in this function have been replaced with a call to CRavenBMI::GetGridSize(GetVarGrid(name)) to simplify logic a bit.

robmtud and others added 3 commits August 19, 2026 15:44
This uses 'CRavenBMI::GetVarNbytes' to determine the output buffer size
in the 'memcpy' call to write the ouput values.

Previously a call to 'CModel::GetNumHRUs' was used to determine the grid
size of the output variable. In the case that the number of HRUs is
larger than the number of sub basins this can cause a segmenation fault
if GetValue is called with an output buffer allocated for a variable on
the sub basin grid.
@analytophile
analytophile merged commit 18eb6df into CSHS-CWRA:main Aug 19, 2026
3 of 4 checks passed
@robmtud
robmtud deleted the robmtud/BMI_GetValue_gridsize branch August 20, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants