On 12.09.25 12:10, Haofeng Li wrote:
From: David Hildenbrand <da...@redhat.com>
What do you think happens when a process exits? :)
Correct! All memory ever allocated to that process gets freed, avoiding
any memory leaks.
Thanks for pointing this out. You are absolutely correct that the operating
system will reclaim all allocated memory when a process exits, so there is no
persistent memory leak in this specific scenario.
I opted to add explicit memory freeing in the error path primarily as a
practice for better long-term maintainability:
It ensures correctness if the code structure changes in the future (e.g.,
becomes part of a longer-running routine).
It maintains consistency with other error paths in the codebase.
It prevents false positives from static analysis tools (like valgrind).
I'm happy to adjust it if you still think it's preferable to remove the free()
in this context.
No code changes are required. This patch adds more complexity without
any benefit.
--
Cheers
David / dhildenb