Make sure that shape strings are post-fixed with a null-char when read from file.

fixes #85
This commit is contained in:
manuelk 2012-12-11 11:40:57 -08:00
parent 10c687ecd5
commit 4b199f7587

View File

@ -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 );
}