[Lldb-commits] [lldb] 446e4e4 - [lldb/Reproducers] Account for char** being a nullptr

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 29 16:41:42 PST 2020


Author: Jonas Devlieghere
Date: 2020-01-29T16:32:48-08:00
New Revision: 446e4e4cf6d1126b4dc2fe816d4bb01b184b2e64

URL: https://github.com/llvm/llvm-project/commit/446e4e4cf6d1126b4dc2fe816d4bb01b184b2e64
DIFF: https://github.com/llvm/llvm-project/commit/446e4e4cf6d1126b4dc2fe816d4bb01b184b2e64.diff

LOG: [lldb/Reproducers] Account for char** being a nullptr

Added: 
    

Modified: 
    lldb/include/lldb/Utility/ReproducerInstrumentation.h
    lldb/source/Utility/ReproducerInstrumentation.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
index ca92f9f2f6e6..9dbe8dc547f5 100644
--- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h
+++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
@@ -606,9 +606,14 @@ class Serializer {
   }
 
   void Serialize(const char **t) {
+    size_t size = 0;
+    if (!t) {
+      Serialize(size);
+      return;
+    }
+
     // Compute the size of the array.
     const char *const *temp = t;
-    size_t size = 0;
     while (*temp++)
       size++;
     Serialize(size);

diff  --git a/lldb/source/Utility/ReproducerInstrumentation.cpp b/lldb/source/Utility/ReproducerInstrumentation.cpp
index fb39fec41d43..4109f73bfef3 100644
--- a/lldb/source/Utility/ReproducerInstrumentation.cpp
+++ b/lldb/source/Utility/ReproducerInstrumentation.cpp
@@ -42,6 +42,8 @@ template <> const char *Deserializer::Deserialize<const char *>() {
 
 template <> const char **Deserializer::Deserialize<const char **>() {
   size_t size = Deserialize<size_t>();
+  if (size == 0)
+    return nullptr;
   const char **r =
       reinterpret_cast<const char **>(calloc(size + 1, sizeof(char *)));
   for (size_t i = 0; i < size; ++i)


        


More information about the lldb-commits mailing list