Addressed asan failures caused by misuse of APIs within unit tests.
authorJared Mulconry <jaredmulconry@gmail.com>
Sun, 1 Oct 2017 08:25:43 +0000 (19:25 +1100)
committerTuro Lamminen <turotl@gmail.com>
Mon, 2 Oct 2017 08:03:18 +0000 (11:03 +0300)
test/unit/utObjTools.cpp
test/unit/utSharedPPData.cpp

index b359cfa..2d9e277 100644 (file)
@@ -106,8 +106,9 @@ TEST_F( utObjTools, countComponents_TwoLines_Success ) {
     TestObjFileParser test_parser;
     std::string data( "-2.061493116917992e-15 -0.9009688496589661 \\\n-0.4338837265968323" );
     std::vector<char> buffer;
-    buffer.resize( data.size() );
+    buffer.resize( data.size() + 1 );
     ::memcpy( &buffer[ 0 ], &data[ 0 ], data.size() );
+    buffer[ buffer.size() - 1 ] = '\0';
     test_parser.setBuffer( buffer );
 
     size_t numComps = test_parser.testGetNumComponentsInDataDefinition();
index e075365..495faa7 100644 (file)
@@ -92,7 +92,7 @@ TEST_F(SharedPPDataTest, testPODProperty)
 // ------------------------------------------------------------------------------------------------
 TEST_F(SharedPPDataTest, testPropertyPointer)
 {
-    int *i = new int[35];
+    int *i = new int;
     shared->AddProperty("test16",i);
     int* o;
     EXPECT_TRUE(shared->GetProperty("test16",o));