Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/simpleini.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrodie Thiesfield <brofield@gmail.com>2012-08-16 00:53:03 +0400
committerBrodie Thiesfield <brofield@gmail.com>2012-08-16 00:53:03 +0400
commit866b3974fcb7297b2ee39312e579bb19df127ad5 (patch)
tree43a28612b4c6778faff004abf33f82615cbc4974
parentb0527ae8ecf59867903bf39ca8ebe5a590269f35 (diff)
Ensure that the file buffer is always null terminated (thanks to irov13 for bug notification and patch)
-rw-r--r--SimpleIni.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/SimpleIni.h b/SimpleIni.h
index b876479..39769d9 100644
--- a/SimpleIni.h
+++ b/SimpleIni.h
@@ -1355,10 +1355,15 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::LoadFile(
if (lSize == 0) {
return SI_OK;
}
- char * pData = new char[lSize];
+
+ // allocate and ensure NULL terminated
+ char * pData = new char[lSize+1];
if (!pData) {
return SI_NOMEM;
}
+ pData[lSize] = 0;
+
+ // load data into buffer
fseek(a_fpFile, 0, SEEK_SET);
size_t uRead = fread(pData, sizeof(char), lSize, a_fpFile);
if (uRead != (size_t) lSize) {