Fix undefined behaviour in data formatter test -- ensure char* null-terminated
authorDaniel Malea <daniel.malea@intel.com>
Tue, 25 Jun 2013 20:54:24 +0000 (20:54 +0000)
committerDaniel Malea <daniel.malea@intel.com>
Tue, 25 Jun 2013 20:54:24 +0000 (20:54 +0000)
so LLDB does not read off the end of the array.

llvm-svn: 184877

lldb/test/functionalities/data-formatter/data-formatter-advanced/main.cpp

index 8e5ea0c..2462e28 100644 (file)
@@ -61,8 +61,11 @@ struct SimpleWithPointers
        SimpleWithPointers(int X, float Y, char Z) :
        x(new int (X)),
        y(new float (Y)),
-       z(new char (Z))
-       {}
+       z(new char[2])
+       {
+          z[0] = Z;
+          z[1] = '\0';
+        }
 };
 
 struct Couple
@@ -168,4 +171,4 @@ int main (int argc, const char * argv[])
     VeryLong a_long_guy;
     
     return 0; // Set break point at this line.
-}
\ No newline at end of file
+}