[llvm] fe1491b - [Support] Fix memory leak induced by `sys::RemoveFileOnSignal` (#159984)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 1 07:55:38 PDT 2025
Author: Alexandre Ganea
Date: 2025-11-01T10:55:34-04:00
New Revision: fe1491b7258aaf821cda89d5ed5f5c5248007136
URL: https://github.com/llvm/llvm-project/commit/fe1491b7258aaf821cda89d5ed5f5c5248007136
DIFF: https://github.com/llvm/llvm-project/commit/fe1491b7258aaf821cda89d5ed5f5c5248007136.diff
LOG: [Support] Fix memory leak induced by `sys::RemoveFileOnSignal` (#159984)
Before this PR, `FilesToRemove` was constructed but never deleted.
Added:
Modified:
llvm/lib/Support/Windows/Signals.inc
Removed:
################################################################################
diff --git a/llvm/lib/Support/Windows/Signals.inc b/llvm/lib/Support/Windows/Signals.inc
index 648d6a50287ec..da68994970ebb 100644
--- a/llvm/lib/Support/Windows/Signals.inc
+++ b/llvm/lib/Support/Windows/Signals.inc
@@ -421,8 +421,13 @@ bool sys::RemoveFileOnSignal(StringRef Filename, std::string *ErrMsg) {
return true;
}
- if (FilesToRemove == NULL)
+ if (FilesToRemove == NULL) {
FilesToRemove = new std::vector<std::string>;
+ std::atexit([]() {
+ delete FilesToRemove;
+ FilesToRemove = NULL;
+ });
+ }
FilesToRemove->push_back(std::string(Filename));
More information about the llvm-commits
mailing list