Avoid LLDB crash upon DW_OP_deref* with empty stack

As done in other DW_OP_* cases, return an error if the stack is empty
rather than eventually crashing elsewhere.  Encountered on big-endian
MIPS, where LLVM bugs currently result in invalid .debug_loc data.

llvm-svn: 199110
This commit is contained in:
Ed Maste 2014-01-13 14:53:09 +00:00
parent 7d074a5ad6
commit 9344787636
1 changed files with 12 additions and 0 deletions

View File

@ -1429,6 +1429,12 @@ DWARFExpression::Evaluate
//----------------------------------------------------------------------
case DW_OP_deref:
{
if (stack.empty())
{
if (error_ptr)
error_ptr->SetErrorString("Expression stack empty for DW_OP_deref.");
return false;
}
Value::ValueType value_type = stack.back().GetValueType();
switch (value_type)
{
@ -1504,6 +1510,12 @@ DWARFExpression::Evaluate
//----------------------------------------------------------------------
case DW_OP_deref_size:
{
if (stack.empty())
{
if (error_ptr)
error_ptr->SetErrorString("Expression stack empty for DW_OP_deref_size.");
return false;
}
uint8_t size = opcodes.GetU8(&offset);
Value::ValueType value_type = stack.back().GetValueType();
switch (value_type)