diff options
author | Leo Koppel <leo.koppel@gmail.com> | 2016-07-22 19:32:02 +0300 |
---|---|---|
committer | Leo Koppel <leo.koppel@gmail.com> | 2016-07-22 19:32:02 +0300 |
commit | 66a7ead100f7f41c14afc0ab528a46f928a9f3d8 (patch) | |
tree | 3543342df874453699b1ecf3158f1edeb5dbdcc3 | |
parent | e850d4e1cae65ee10f60992c5a576dce7fe35220 (diff) |
Fix failure on loading empty file
Re: brofield/simpleini#19
The Windows, Unicode, UTF-8 version of SizeFromStore returns failure when
given zero-length data. Fix by moving a_uDataLen == 0 check to after the
UTF-8 BOM removal.
-rw-r--r-- | SimpleIni.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/SimpleIni.h b/SimpleIni.h index aee5bee..b0cad33 100644 --- a/SimpleIni.h +++ b/SimpleIni.h @@ -1416,10 +1416,6 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::LoadData( { SI_CONVERTER converter(m_bStoreIsUtf8); - if (a_uDataLen == 0) { - return SI_OK; - } - // consume the UTF-8 BOM if it exists if (m_bStoreIsUtf8 && a_uDataLen >= 3) { if (memcmp(a_pData, SI_UTF8_SIGNATURE, 3) == 0) { @@ -1428,6 +1424,10 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::LoadData( } } + if (a_uDataLen == 0) { + return SI_OK; + } + // determine the length of the converted data size_t uLen = converter.SizeFromStore(a_pData, a_uDataLen); if (uLen == (size_t)(-1)) { |