[Lldb-commits] [lldb] r199110 - Avoid LLDB crash upon DW_OP_deref* with empty stack

Ed Maste emaste at freebsd.org
Mon Jan 13 06:53:09 PST 2014


Author: emaste
Date: Mon Jan 13 08:53:09 2014
New Revision: 199110

URL: http://llvm.org/viewvc/llvm-project?rev=199110&view=rev
Log:
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.

Modified:
    lldb/trunk/source/Expression/DWARFExpression.cpp

Modified: lldb/trunk/source/Expression/DWARFExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=199110&r1=199109&r2=199110&view=diff
==============================================================================
--- lldb/trunk/source/Expression/DWARFExpression.cpp (original)
+++ lldb/trunk/source/Expression/DWARFExpression.cpp Mon Jan 13 08:53:09 2014
@@ -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)





More information about the lldb-commits mailing list