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
}
void MCStreamer::Finish() {
- if (!DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End)
- getContext().reportError(SMLoc(), "Unfinished frame!");
- if (!WinFrameInfos.empty() && !WinFrameInfos.back()->End)
+ if ((!DwarfFrameInfos.empty() && !DwarfFrameInfos.back().End) ||
+ (!WinFrameInfos.empty() && !WinFrameInfos.back()->End)) {
getContext().reportError(SMLoc(), "Unfinished frame!");
+ return;
+ }
MCTargetStreamer *TS = getTargetStreamer();
if (TS)
--- /dev/null
+# RUN: not llvm-mc %s -filetype=obj -triple=x86_64-unknown-linux \
+# RUN: -o /dev/null 2>&1 | FileCheck %s
+
+## Check we don't crash on unclosed frame scope.
+# CHECK: error: Unfinished frame!
+
+.text
+.globl foo
+foo:
+ .cfi_startproc