[MC] - Don't crash on unclosed frame.
llvm-mc can crash when
there is cfi_startproc without cfi_end_proc:
.text
.globl foo
foo:
.cfi_startproc
Testcase shows the issue, patch fixes it.
Differential revision: https://reviews.llvm.org/D43456
llvm-svn: 325564
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index bc9c93f..a2c58e6 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -816,10 +816,11 @@
}
void MCStreamer::Finish() {
- if (!DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End)
+ if ((!DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End) ||
+ (!WinFrameInfos.empty() && !WinFrameInfos.back()->End)) {
getContext().reportError(SMLoc(), "Unfinished frame!");
- if (!WinFrameInfos.empty() && !WinFrameInfos.back()->End)
- getContext().reportError(SMLoc(), "Unfinished frame!");
+ return;
+ }
MCTargetStreamer *TS = getTargetStreamer();
if (TS)