Repository navigation
BUG: Free the strings that -cbl and the FSL name check allocate - #139
Merged
Merged
Conversation
act_cbl() in both tools returned without freeing the strdup'd file name and selector when the input could not be read, and fslio's check_for_multiple_filenames() never freed its basename. Tagging the allocating functions' prototypes with the malloc attribute makes scan-build report all three, so they are fixed first. The new tests reach the -cbl path with a missing input; the sanitizer leg fails them if the strings leak.
hjmjohnson
marked this pull request as ready for review
November 14, 2026 15:24
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.
Frees the strings that
-cbl(both tools) and fslio'scheck_for_multiple_filenames()leak. These are the leaks scan-build reports once #138'sNIO_RETURNS_MALLOCEDmoves from the definitions to the header prototypes; with this and #101 merged, that move leaves CI'sscan-build --status-bugsleg clean.What leaked and how it is tested
act_cbl()innifti_tool.candnifti1_tool.creturned without freeing thenifti_strdup'dfnameandselstrwhen the input could not be read.check_for_multiple_filenames()infslio.cnever freedbasenamefromnifti_makebasename().New tests
nifti_tool_cbl_missing_inputandnifti1_tool_cbl_missing_inputreach the-cblfailure path with a missing input. Like the existing_tool_ascii_dup_attrtest, they pass on the expected diagnostic and fail onLeakSanitizer|leaked in, so the sanitize-clang-linux leg fails them if the strings leak.Red-green, locally on macOS (LeakSanitizer is unavailable on Apple Silicon), with
leaks --atExit: 2 leaks (64 bytes) per tool with the fix reverted, 0 with it.The fslio path has no test; nothing in the suite reaches it. The analyzer is its check.
Sequence for #138
dupname/nhdrleaks inact_mod_hdrsand friends.-cbland fslio leaks.NIO_RETURNS_MALLOCEDon the 7 prototypes in each header, so callers outside the defining file (the tools, ITK, AFNI) get the leak checks.Verified locally: this branch plus #101 plus prototype-tagged headers gives scan-build only the 3 cifti reports that master already shows with the local LLVM.