mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-01-21 05:00:06 -05:00
--Bug fixes
-Another attempt to fix null termination bug with reading files for Xml processing.
This commit is contained in:
parent
9a56f286b2
commit
26e075def5
@ -332,12 +332,12 @@ static bool ReadFile(const char* filename, string& buf, bool nullTerminate = tru
|
|||||||
|
|
||||||
if (const auto pos = ifs.tellg())//Ensure it exists and wasn't empty.
|
if (const auto pos = ifs.tellg())//Ensure it exists and wasn't empty.
|
||||||
{
|
{
|
||||||
buf.resize(pos + streampos(nullTerminate ? 1 : 0));
|
buf.resize(pos);// +streampos(nullTerminate ? 1 : 0));
|
||||||
ifs.seekg(0, ios::beg);
|
ifs.seekg(0, ios::beg);
|
||||||
ifs.read(&buf[0], pos);
|
ifs.read(&buf[0], pos);
|
||||||
|
|
||||||
if (nullTerminate && (buf[buf.size() - 1] != 0))//Optionally NULL terminate if they want to treat it as a string, and it's not terminated arleady.
|
if (nullTerminate && (buf[buf.size() - 1] != 0))//Optionally NULL terminate if they want to treat it as a string, and it's not terminated arleady.
|
||||||
buf[buf.size() - 1] = 0;
|
buf.push_back(0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user