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>2013-02-01 05:44:24 +0400
committerBrodie Thiesfield <brofield@gmail.com>2013-02-01 05:44:24 +0400
commit50284d3a634eb1173abac87e12d3c3addd8d3775 (patch)
tree62c9facc22f00d50c8f9eaee2b58a2e4f6ac6023
parent3a12fb6e4847e081985d87f53d8b874434e581d8 (diff)
Fix for issue 7: mbstowcs is used in non-standard way, thus casing crash with gcc
-rw-r--r--SimpleIni.h22
1 files changed, 14 insertions, 8 deletions
diff --git a/SimpleIni.h b/SimpleIni.h
index 04e2b48..534e190 100644
--- a/SimpleIni.h
+++ b/SimpleIni.h
@@ -2836,9 +2836,15 @@ public:
// the source text.
return a_uInputDataLen;
}
- else {
- return mbstowcs(NULL, a_pInputData, a_uInputDataLen);
- }
+
+#if !defined(_WIN32) && !defined(_linux)
+ // fall back processing for platforms that don't support C99 usage of mbstowcs
+ // worst case scenario is 1:1, this should be a sufficient buffer size
+ return a_uInputDataLen;
+#else
+ // get the actual required buffer size
+ return mbstowcs(NULL, a_pInputData, a_uInputDataLen);
+#endif
}
/** Convert the input string from the storage format to SI_CHAR.
@@ -2884,11 +2890,11 @@ public:
}
return retval == conversionOK;
}
- else {
- size_t retval = mbstowcs(a_pOutputData,
- a_pInputData, a_uOutputDataSize);
- return retval != (size_t)(-1);
- }
+
+ // convert to wchar_t
+ size_t retval = mbstowcs(a_pOutputData,
+ a_pInputData, a_uOutputDataSize);
+ return retval != (size_t)(-1);
}
/** Calculate the number of char required by the storage format of this