Skip to content

Fix premature assignment to optional argument before checking existence#1441

Merged
mgduda merged 1 commit intoMPAS-Dev:release-v8.4.0from
islas:bugfix_streammgr_optierr
Apr 9, 2026
Merged

Fix premature assignment to optional argument before checking existence#1441
mgduda merged 1 commit intoMPAS-Dev:release-v8.4.0from
islas:bugfix_streammgr_optierr

Conversation

@islas
Copy link
Copy Markdown
Contributor

@islas islas commented Apr 6, 2026

This PR fixes an issue within mpas_get_stream_filename() where the optional argument ierr was being assigned to before checking if it was passed in.

The routine now checks if ierr is present, and if so initializes it to MPAS_STREAM_MGR_NOERR.

Comment thread src/framework/mpas_stream_manager.F
@islas islas force-pushed the bugfix_streammgr_optierr branch 2 times, most recently from 098a7c6 to f0a4ba9 Compare April 7, 2026 21:05
@mgduda mgduda self-requested a review April 8, 2026 23:20
If no optional `ierr` argument is provided in calling the subroutine
`mpas_get_stream_filename()` the model segfaults by trying to assign to
the nonexistent argument. Additionally, `ierr` is set to zero to
initialize, but as this module uses its own error codes it should
instead use `MPAS_STREAM_MGR_NOERR`.

This change checks if `ierr` is present, and if so initializes it to
`MPAS_STREAM_MGR_NOERR`.
@islas islas force-pushed the bugfix_streammgr_optierr branch from f0a4ba9 to 44ee2f8 Compare April 8, 2026 23:35
Copy link
Copy Markdown
Contributor

@mgduda mgduda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix, and for spotting this issue!

@mgduda mgduda merged commit c0f839d into MPAS-Dev:release-v8.4.0 Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants