diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -252,10 +252,13 @@ stack_t AltStack = {}; AltStack.ss_sp = static_cast(safe_malloc(AltStackSize)); - NewAltStackPointer = AltStack.ss_sp; // Save to avoid reporting a leak. AltStack.ss_size = AltStackSize; - if (sigaltstack(&AltStack, &OldAltStack) != 0) + if (sigaltstack(&AltStack, &OldAltStack) != 0) { free(AltStack.ss_sp); + } else { + free(NewAltStackPointer); + NewAltStackPointer = AltStack.ss_sp; // Save to avoid reporting a leak. + } } #else static void CreateSigAltStack() {}