Skip to content

Avoid allocating the torrent output path twice - #323

Merged
rhash merged 1 commit into
rhash:masterfrom
dajiaohuang:fix-315-torrent-path-leak
Oct 4, 2026
Merged

rhash merged 1 commit into
rhash:masterfrom
dajiaohuang:fix-315-torrent-path-leak

Conversation

@dajiaohuang

Copy link
Copy Markdown
Contributor

Saving a torrent allocates its output path twice with identical file_modify_path() calls. The second call overwrites the first allocation, leaking a path for every saved torrent. Remove the unused first call and retain the existing error-handling call.

Closes #315. Extracted as an independent fix from #321.

Validation: compiled the focused patch against master 3dbba4b on Ubuntu/GCC 13.3 with AddressSanitizer and SHA-NI disabled. Actual rhash --torrent tests/test1K.data saves the torrent and exits successfully without a leak report. Restoring only the duplicate call in a control build produces a LeakSanitizer report of 26 bytes in one str_replace_n allocation and exits 1. git diff --check passes. Other platforms and the full CLI suite were not exercised for this focused patch.

@rhash
rhash merged commit 766fa28 into rhash:master Oct 4, 2026
3 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.

Avoid allocating the torrent output path twice

2 participants