[llvm] [Support] Fix memory leak induced by `sys::RemoveFileOnSignal` (PR #159984)

Alexandre Ganea via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 21 09:13:55 PDT 2025


================
@@ -421,8 +421,13 @@ bool sys::RemoveFileOnSignal(StringRef Filename, std::string *ErrMsg) {
     return true;
   }
 
-  if (FilesToRemove == NULL)
+  if (FilesToRemove == NULL) {
----------------
aganea wrote:

I was thinking about that. However if we make it a non-pointer, and it is destroyed during global destruction; if any other subsequent global variable destructor code tries to access `FilesToRemove`, that might crash in unexpected ways. Whereas here, as a pointer, it is clearly set to `NULL` and we already check `if (FilesToRemove != NULL)` in all the APIs.

https://github.com/llvm/llvm-project/pull/159984


More information about the llvm-commits mailing list