From 795cc3afc3009eb47365e852abe8cfae40683eff Mon Sep 17 00:00:00 2001 From: Daniel Malea Date: Tue, 25 Jun 2013 20:54:24 +0000 Subject: [PATCH] Fix undefined behaviour in data formatter test -- ensure char* null-terminated so LLDB does not read off the end of the array. llvm-svn: 184877 --- .../data-formatter/data-formatter-advanced/main.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lldb/test/functionalities/data-formatter/data-formatter-advanced/main.cpp b/lldb/test/functionalities/data-formatter/data-formatter-advanced/main.cpp index 8e5ea0c..2462e28 100644 --- a/lldb/test/functionalities/data-formatter/data-formatter-advanced/main.cpp +++ b/lldb/test/functionalities/data-formatter/data-formatter-advanced/main.cpp @@ -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 +} -- 2.7.4