BUG: Do not write to the stream that failed to open - #129
Open
hjmjohnson wants to merge 2 commits into
Open
hjmjohnson wants to merge 2 commits into
hjmjohnson wants to merge 2 commits into
Conversation
open_write_stream() returns NULL when its fopen() fails, and reports it. Both callers then used the result without testing it. $ cifti_tool -input c.nii -disp_cext -output /nonexistent-dir/x.txt ** failed to open '/nonexistent-dir/x.txt' for writing Segmentation fault (core dumped) disp_cifti_extension() passes it to fprintf(). eval_cifti_extension() hands it to axml_set_wstream(), so the NULL becomes the xml library's write stream and every later write follows it. Both now return 1; the message has already been printed. This file is behind USE_CIFTI_CODE, which defaults to OFF, so the standard workflows do not compile it. Verified with -DUSE_CIFTI_CODE=ON. (cherry picked from commit f368af9)
Driven through a cmake -P script rather than add_test, because PASS_REGULAR_EXPRESSION ignores the exit status and a crash that had already printed the diagnostic would pass. The script pins that the tool exits normally and reports the failure, and that an openable -output is still written with the extension in it, so refusing every write would not pass. (cherry picked from commit 5c08eb3)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-submission of #72, reverted from
masteron 2026-09-24. Content isunchanged from the original.
Position 7 of 11 in the deep stack. Base:
stack/fix-fslio-64bit-arithmetic.Based on the pull request above it in the stack, so the diff shown here is
this change alone. Merge the stack bottom-up.
Stack order
stack/test-regression-coveragemasterstack/pr-fix-alloc-null-checksstack/test-regression-coveragestack/fix-axml-skip-depthstack/pr-fix-alloc-null-checksstack/pr-fix-analyzer-leaksstack/fix-axml-skip-depthstack/pr-fix-sign-conversionstack/pr-fix-analyzer-leaksstack/fix-fslio-64bit-arithmeticstack/pr-fix-sign-conversionstack/fix-cifti-null-stream<- this PRstack/fix-fslio-64bit-arithmeticstack/pr-fix-calloc-transposed-argsstack/fix-cifti-null-streamstack/pr-fix-shorten-64-to-32stack/pr-fix-calloc-transposed-argsstack/fix-image-read-complex-checkstack/pr-fix-shorten-64-to-32stack/pr-fix-xml-read-errorsstack/fix-image-read-complex-checkThe order is the order these changes sat on
masterbefore the revert, soit builds and tests at every step.
Commits introduced by this PR
Ordering for all the re-submitted work is tracked in #84.