Skip to content

Fix uninitialized memory reads found by valgrind#145

Merged
vfonov merged 1 commit intoBIC-MNI:developfrom
gdevenyi:fix-valgrind
Mar 31, 2026
Merged

Fix uninitialized memory reads found by valgrind#145
vfonov merged 1 commit intoBIC-MNI:developfrom
gdevenyi:fix-valgrind

Conversation

@gdevenyi
Copy link
Copy Markdown
Contributor

Summary

  • Initialize derv_usr_float and derv_var_float in miicv_create() so miicv_ndattach() does not read uninitialized heap memory when the user_do_range path skips MI_icv_get_norm()
  • Zero-initialize the stack-allocated VIO_multidim_array in multidim_test so multidim_array_is_alloced() does not branch on an indeterminate n_dimensions

Test plan

  • Full test suite (56/56 tests pass)
  • All test binaries run clean under valgrind --leak-check=full --track-origins=yes with 0 errors and 0 definite/possible leaks
  • Includes minc2-leak-test (100K iterations, 5.6M allocs, 0 leaks under valgrind)

🤖 Generated with Claude Code Opus 4.6 with maximum effort

Prompt

Compile and run the tests under valgrind. Enable NIFTI support. Make the minimal changes to address any bugs.

Initialize derv_usr_float and derv_var_float in miicv_create() so
miicv_ndattach() does not read garbage when the user_do_range path
skips MI_icv_get_norm(). Zero-initialize the stack-allocated
VIO_multidim_array in multidim_test so multidim_array_is_alloced()
does not branch on an indeterminate n_dimensions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gdevenyi gdevenyi requested a review from vfonov March 30, 2026 17:11
@vfonov vfonov merged commit a81d831 into BIC-MNI:develop Mar 31, 2026
12 checks passed
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