Skip to content

Fix premature assignment to optional argument before checking existence#1441

Open
islas wants to merge 1 commit intoMPAS-Dev:release-v8.4.0from
islas:bugfix_streammgr_optierr
Open

Fix premature assignment to optional argument before checking existence#1441
islas wants to merge 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

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. The function already has the necessary variables to capture local errors and then pass the value back to the caller, as is common in other routines throughout MPAS.

These changes make use of the existing variable that may have just been unintentionally unused.

@@ -4107,6 +4107,10 @@ subroutine mpas_get_stream_filename(manager, streamID, when, blockID, filename,
end if
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This if( present() ) statement above (line 4104) makes use of ierr and assigns to it instead of ierr_local - @mgduda I think it may make sense to also modify the assignment so that the final ierr assignment has the correct error code.

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.

1 participant