From 657a06c61928eb0ac36f58b5da71fc43785324f4 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Fri, 30 Aug 2019 22:25:55 +0000 Subject: [MC] Avoid crashes from improperly nested or wrong target .seh_handlerdata directives llvm-svn: 370540 --- llvm/lib/MC/MCAsmStreamer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'llvm/lib/MC/MCAsmStreamer.cpp') diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp index 2b9bec38b40..d2f99efef22 100644 --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -1748,6 +1748,12 @@ void MCAsmStreamer::EmitWinEHHandlerData(SMLoc Loc) { // We only do this so the section switch that terminates the handler // data block is visible. WinEH::FrameInfo *CurFrame = getCurrentWinFrameInfo(); + + // Do nothing if no frame is open. MCStreamer should've already reported an + // error. + if (!CurFrame) + return; + MCSection *TextSec = &CurFrame->Function->getSection(); MCSection *XData = getAssociatedXDataSection(TextSec); SwitchSectionNoChange(XData); -- cgit v1.2.3