mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-27 21:00:33 +05:00
fix bug of invalid file read - a garbage is in the end of string data
This commit is contained in:
parent
298eadbd92
commit
fb394a9bd6
@ -24,9 +24,11 @@ namespace XAO
|
|||||||
rstr.open(filePath.c_str());
|
rstr.open(filePath.c_str());
|
||||||
rstr.seekg(0, rstr.end); // go to the end
|
rstr.seekg(0, rstr.end); // go to the end
|
||||||
length = rstr.tellg(); // report location (this is the length)
|
length = rstr.tellg(); // report location (this is the length)
|
||||||
|
printf("---------------------------VSR: length=%ld\n", length);
|
||||||
rstr.seekg(0, rstr.beg); // go back to the beginning
|
rstr.seekg(0, rstr.beg); // go back to the beginning
|
||||||
char* txt = new char[length]; // allocate memory for a buffer of appropriate dimension
|
char* txt = new char[length+1]; // allocate memory for a buffer of appropriate dimension
|
||||||
rstr.read(txt, length); // read the whole file into the buffer
|
rstr.read(txt, length); // read the whole file into the buffer
|
||||||
|
txt[length] = '\0';
|
||||||
rstr.close();
|
rstr.close();
|
||||||
|
|
||||||
return txt;
|
return txt;
|
||||||
|
Loading…
Reference in New Issue
Block a user