From 26e075def520bbfb823f9dea0338262832144b1a Mon Sep 17 00:00:00 2001 From: Person Date: Fri, 8 Mar 2024 10:14:21 -0700 Subject: [PATCH] --Bug fixes -Another attempt to fix null termination bug with reading files for Xml processing. --- Source/Ember/Utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Ember/Utils.h b/Source/Ember/Utils.h index 394515f..37728a7 100644 --- a/Source/Ember/Utils.h +++ b/Source/Ember/Utils.h @@ -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. { - buf.resize(pos + streampos(nullTerminate ? 1 : 0)); + buf.resize(pos);// +streampos(nullTerminate ? 1 : 0)); ifs.seekg(0, ios::beg); 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. - buf[buf.size() - 1] = 0; + buf.push_back(0); return true; }