[Lldb-commits] [lldb] r358137 - Fix undefined behavior in DWARFASTParser::ParseChildArrayInfo()

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 10 14:18:45 PDT 2019


Author: adrian
Date: Wed Apr 10 14:18:44 2019
New Revision: 358137

URL: http://llvm.org/viewvc/llvm-project?rev=358137&view=rev
Log:
Fix undefined behavior in DWARFASTParser::ParseChildArrayInfo()

PR40827: https://bugs.llvm.org/show_bug.cgi?id=40827
<rdar://problem/48729057>

Modified:
    lldb/trunk/include/lldb/Symbol/SymbolFile.h
    lldb/trunk/packages/Python/lldbsuite/test/lang/c/array_types/TestArrayTypes.py

Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=358137&r1=358136&r2=358137&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Wed Apr 10 14:18:44 2019
@@ -132,10 +132,10 @@ public:
 
   /// The characteristics of an array type.
   struct ArrayInfo {
-    int64_t first_index;
+    int64_t first_index = 0;
     llvm::SmallVector<uint64_t, 1> element_orders;
-    uint32_t byte_stride;
-    uint32_t bit_stride;
+    uint32_t byte_stride = 0;
+    uint32_t bit_stride = 0;
   };
   /// If \c type_uid points to an array type, return its characteristics.
   /// To support variable-length array types, this function takes an

Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/c/array_types/TestArrayTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/array_types/TestArrayTypes.py?rev=358137&r1=358136&r2=358137&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/c/array_types/TestArrayTypes.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/array_types/TestArrayTypes.py Wed Apr 10 14:18:44 2019
@@ -175,6 +175,8 @@ class ArrayTypesTestCase(TestBase):
         self.DebugSBValue(variable)
         self.assertTrue(variable.GetNumChildren() == 4,
                         "Variable 'strings' should have 4 children")
+        byte_size = variable.GetByteSize()
+        self.assertTrue(byte_size >= 4*4 and byte_size <= 1024)
 
         child3 = variable.GetChildAtIndex(3)
         self.DebugSBValue(child3)




More information about the lldb-commits mailing list