Skip to content

Commit 01238f4

Browse files
committed
fixed:sometime configure read memory leak
1 parent 6999891 commit 01238f4

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -229,21 +229,12 @@ bool CModuleConfigure_Json::ModuleConfigure_Json_Versions(LPCXSTR lpszConfigFile
229229
Config_dwErrorCode = ERROR_MODULE_CONFIGURE_JSON_OPENFILE;
230230
return false;
231231
}
232-
size_t nCount = 0;
233-
XCHAR tszMsgBuffer[4096];
234-
while (1)
235-
{
236-
size_t nRet = fread(tszMsgBuffer + nCount, 1, 2048, pSt_File);
237-
if (nRet <= 0)
238-
{
239-
break;
240-
}
241-
nCount += nRet;
242-
}
232+
XCHAR tszMsgBuffer[8192] = {};
233+
size_t nRet = fread(tszMsgBuffer, 1, sizeof(tszMsgBuffer), pSt_File);
243234
fclose(pSt_File);
244235
//开始解析配置文件
245236
std::unique_ptr<Json::CharReader> const pSt_JsonReader(st_JsonBuilder.newCharReader());
246-
if (!pSt_JsonReader->parse(tszMsgBuffer, tszMsgBuffer + nCount, &st_JsonRoot, &st_JsonError))
237+
if (!pSt_JsonReader->parse(tszMsgBuffer, tszMsgBuffer + nRet, &st_JsonRoot, &st_JsonError))
247238
{
248239
Config_IsErrorOccur = true;
249240
Config_dwErrorCode = ERROR_MODULE_CONFIGURE_JSON_PARSE;

0 commit comments

Comments
 (0)