More pre-release fixes

This commit is contained in:
binarymaster 2014-12-10 23:19:31 +03:00
parent f0d5f3a6de
commit bca5e184ad
1 changed files with 11 additions and 2 deletions

View File

@ -164,6 +164,8 @@ bool INI_FILE::FillVariable(INI_SECTION_VARIABLE *Variable, char *Str, DWORD Str
if (Str[i] == '"' || Str[i] == '\'') Quotes = !Quotes; if (Str[i] == '"' || Str[i] == '\'') Quotes = !Quotes;
if (Str[i] == '=' && !Quotes) if (Str[i] == '=' && !Quotes)
{ {
memset(Variable->VariableName, 0, MAX_STRING_LEN);
memset(Variable->VariableValue, 0, MAX_STRING_LEN);
memcpy(Variable->VariableName, Str, i); memcpy(Variable->VariableName, Str, i);
memcpy(Variable->VariableValue, &(Str[i + 1]), StrSize - (i - 1)); memcpy(Variable->VariableValue, &(Str[i + 1]), StrSize - (i - 1));
StrTrim(Variable->VariableName); StrTrim(Variable->VariableName);
@ -252,6 +254,7 @@ bool INI_FILE::Parse()
{ {
CurrentSectionNum++; CurrentSectionNum++;
CurrentVariableNum = 0; CurrentVariableNum = 0;
memset(IniData.Section[CurrentSectionNum].SectionName, 0, MAX_STRING_LEN);
memcpy(IniData.Section[CurrentSectionNum].SectionName, &(CurrentString[1]), (CurrentStringSize - 2)); memcpy(IniData.Section[CurrentSectionNum].SectionName, &(CurrentString[1]), (CurrentStringSize - 2));
continue; continue;
} }
@ -271,7 +274,10 @@ PINI_SECTION INI_FILE::GetSection(char *SectionName)
{ {
for (DWORD i = 0; i < IniData.SectionCount; i++) for (DWORD i = 0; i < IniData.SectionCount; i++)
{ {
if (memcmp(IniData.Section[i].SectionName, SectionName, strlen(SectionName)) == 0) if (
(strlen(IniData.Section[i].SectionName) == strlen(SectionName)) &&
(memcmp(IniData.Section[i].SectionName, SectionName, strlen(SectionName)) == 0)
)
{ {
return &IniData.Section[i]; return &IniData.Section[i];
} }
@ -307,7 +313,10 @@ bool INI_FILE::GetVariableInSectionPrivate(char *SectionName, char *VariableName
// Find variable // Find variable
for (DWORD i = 0; i < Section->VariablesCount; i++) for (DWORD i = 0; i < Section->VariablesCount; i++)
{ {
if (memcmp(Section->Variables[i].VariableName, VariableName, strlen(VariableName)) == 0) if (
(strlen(Section->Variables[i].VariableName) == strlen(VariableName)) &&
(memcmp(Section->Variables[i].VariableName, VariableName, strlen(VariableName)) == 0)
)
{ {
Variable = &(Section->Variables[i]); Variable = &(Section->Variables[i]);
break; break;