From 88afefe464213258601f35f4802b75ec2761b740 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 21 Dec 2016 08:51:04 -0800 Subject: [PATCH] Avoid crash in SourceImpl constructor. The Frame constructor calls back into SourceImpl (the passed this reference), and when in-place constructed in the SourceImpl constructor, SourceImpl is only partially constructed. --- src/SourceImpl.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/SourceImpl.cpp b/src/SourceImpl.cpp index 9e1ada29d4..effabe4186 100644 --- a/src/SourceImpl.cpp +++ b/src/SourceImpl.cpp @@ -19,8 +19,9 @@ using namespace cs; static constexpr std::size_t kMaxImagesAvail = 32; -SourceImpl::SourceImpl(llvm::StringRef name) - : m_name{name}, m_frame{*this, llvm::StringRef{}, 0} {} +SourceImpl::SourceImpl(llvm::StringRef name) : m_name{name} { + m_frame = Frame{*this, llvm::StringRef{}, 0}; +} SourceImpl::~SourceImpl() { // Wake up anyone who is waiting. This also clears the current frame,