From 4b199f7587016a40d9bf23966e84b3223087476b Mon Sep 17 00:00:00 2001 From: manuelk Date: Tue, 11 Dec 2012 11:40:57 -0800 Subject: [PATCH] Make sure that shape strings are post-fixed with a null-char when read from file. fixes #85 --- regression/hbr_regression/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/regression/hbr_regression/main.cpp b/regression/hbr_regression/main.cpp index b0e7225f..4fc32d7b 100644 --- a/regression/hbr_regression/main.cpp +++ b/regression/hbr_regression/main.cpp @@ -156,7 +156,7 @@ static shape * readShape( char const * fname ) { size_t size = ftell(handle); fseek( handle, 0, SEEK_SET ); - char * shapeStr = new char[size]; + char * shapeStr = new char[size+1]; if ( fread( shapeStr, size, 1, handle)!=1 ) { printf("Error reading \"%s\" - aborting.\n", fname); @@ -165,6 +165,8 @@ static shape * readShape( char const * fname ) { fclose(handle); + shapeStr[size]='\0'; + return shape::parseShape( shapeStr, 1 ); }