Fix/tsk realloc caller leaks 4.14#35
Merged
jayaramcs merged 5 commits intoSleuthKitLabs:develop-4.14from Mar 12, 2026
Merged
Conversation
Assigning tsk_realloc() result directly back to the source pointer causes a memory leak on failure — the original allocation is lost when NULL is returned. Fixed across all affected call sites by routing through a temporary pointer and only updating the original on success. Affected: - tsk/base/tsk_stack.c (tsk_stack_push) - tsk/fs/fs_attr.cpp (fs_attr_put_name, tsk_fs_attr_set_str) - tsk/fs/fs_dir.cpp (tsk_fs_dir_realloc) - tsk/fs/fs_inode.c (tsk_fs_meta_realloc) - tsk/fs/fs_name.cpp (tsk_fs_name_realloc, tsk_fs_name_copy) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…alk() When iso9660_dinode_copy() fails (e.g. due to tsk_fs_meta_realloc() returning NULL), the error path was freeing dinode but not calling tsk_fs_file_close(fs_file), leaking both fs_file and fs_file->meta. Every other early-return in iso9660_inode_walk() correctly calls tsk_fs_file_close() before returning — this path alone was missing it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…exfatfs_inode_copy_init() fs_meta->name2 is allocated via tsk_malloc just before the tsk_fs_meta_realloc() call. If realloc fails, the original error path returned 1 immediately, leaking name2. Use a temp pointer to preserve the original fs_meta on failure, then free and null name2 before returning. Nulling prevents a double-free if the caller's cleanup path also visits the struct. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
No description provided.