mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-11-09 22:00:06 +00:00
Make sure that shape strings are post-fixed with a null-char when read from file.
fixes #85
This commit is contained in:
parent
10c687ecd5
commit
4b199f7587
@ -156,7 +156,7 @@ static shape * readShape( char const * fname ) {
|
|||||||
size_t size = ftell(handle);
|
size_t size = ftell(handle);
|
||||||
fseek( handle, 0, SEEK_SET );
|
fseek( handle, 0, SEEK_SET );
|
||||||
|
|
||||||
char * shapeStr = new char[size];
|
char * shapeStr = new char[size+1];
|
||||||
|
|
||||||
if ( fread( shapeStr, size, 1, handle)!=1 ) {
|
if ( fread( shapeStr, size, 1, handle)!=1 ) {
|
||||||
printf("Error reading \"%s\" - aborting.\n", fname);
|
printf("Error reading \"%s\" - aborting.\n", fname);
|
||||||
@ -165,6 +165,8 @@ static shape * readShape( char const * fname ) {
|
|||||||
|
|
||||||
fclose(handle);
|
fclose(handle);
|
||||||
|
|
||||||
|
shapeStr[size]='\0';
|
||||||
|
|
||||||
return shape::parseShape( shapeStr, 1 );
|
return shape::parseShape( shapeStr, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user