From bb1beaa220a6f5b21a1ed82515fba92d779de757 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Tue, 26 Mar 2013 18:42:13 +0000 Subject: [PATCH] Don't crash when we have an element size of zero. llvm-svn: 178056 --- lldb/source/DataFormatters/LibCxx.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lldb/source/DataFormatters/LibCxx.cpp b/lldb/source/DataFormatters/LibCxx.cpp index 28e596a..a8be80a2 100644 --- a/lldb/source/DataFormatters/LibCxx.cpp +++ b/lldb/source/DataFormatters/LibCxx.cpp @@ -1,4 +1,4 @@ -//===-- LibCxx.cpp ------------------------------------------------*- C++ -*-===// +//===-- LibCxx.cpp ----------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -402,12 +402,12 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator (CXXSyntheticC } lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::LibcxxStdVectorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp) : -SyntheticChildrenFrontEnd(*valobj_sp.get()), -m_start(NULL), -m_finish(NULL), -m_element_type(), -m_element_size(0), -m_children() + SyntheticChildrenFrontEnd(*valobj_sp.get()), + m_start(NULL), + m_finish(NULL), + m_element_type(), + m_element_size(0), + m_children() { if (valobj_sp) Update(); @@ -466,9 +466,13 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::Update() m_element_type = ClangASTType(data_type_finder_sp->GetClangAST(),data_type_finder_sp->GetClangType()); m_element_type.SetClangType(m_element_type.GetASTContext(), m_element_type.GetPointeeType()); m_element_size = m_element_type.GetTypeByteSize(); - // store raw pointers or end up with a circular dependency - m_start = m_backend.GetChildMemberWithName(ConstString("__begin_"),true).get(); - m_finish = m_backend.GetChildMemberWithName(ConstString("__end_"),true).get(); + + if (m_element_size > 0) + { + // store raw pointers or end up with a circular dependency + m_start = m_backend.GetChildMemberWithName(ConstString("__begin_"),true).get(); + m_finish = m_backend.GetChildMemberWithName(ConstString("__end_"),true).get(); + } return false; } -- 2.7.4