Avoid various uninitialised memory errors while reading Registry.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2017-06-11 10:21:28 +01:00
parent df53415d98
commit 6996c5fc47
3 changed files with 26 additions and 8 deletions

View file

@ -7,3 +7,5 @@ BOOL RegLoadString (LPCTSTR,LPCTSTR,BOOL,LPTSTR,DWORD);
BOOL RegLoadValue (LPCTSTR,LPCTSTR,BOOL,DWORD *); BOOL RegLoadValue (LPCTSTR,LPCTSTR,BOOL,DWORD *);
void RegSaveString (LPCTSTR,LPCTSTR,BOOL,LPCTSTR); void RegSaveString (LPCTSTR,LPCTSTR,BOOL,LPCTSTR);
void RegSaveValue (LPCTSTR,LPCTSTR,BOOL,DWORD); void RegSaveValue (LPCTSTR,LPCTSTR,BOOL,DWORD);
BOOL RegLoadValue (LPCTSTR,LPCTSTR,BOOL,BOOL *);

View file

@ -68,13 +68,13 @@ BOOL RegLoadString (LPCTSTR section, LPCTSTR key, BOOL peruser,
strncpy(buffer, s.c_str(), chars); strncpy(buffer, s.c_str(), chars);
buffer[chars - 1] = 0; buffer[chars - 1] = 0;
result = TRUE; result = TRUE;
LogFileOutput("RegLoadString: %s - %s = %s\n", section, key, buffer);
} }
catch (const std::exception & e) catch (const std::exception & e)
{ {
result = FALSE; result = FALSE;
LogFileOutput("RegLoadString: %s - %s = ??\n", section, key);
} }
LogFileOutput("RegLoadString: %s - %s = %s\n", section, key, buffer);
return result; return result;
} }
@ -85,13 +85,30 @@ BOOL RegLoadValue (LPCTSTR section, LPCTSTR key, BOOL peruser, DWORD *value)
{ {
*value = Configuration::instance->getValue<DWORD>(section, key); *value = Configuration::instance->getValue<DWORD>(section, key);
result = TRUE; result = TRUE;
LogFileOutput("RegLoadValue: %s - %s = %d\n", section, key, *value);
} }
catch (const std::exception & e) catch (const std::exception & e)
{ {
result = FALSE; result = FALSE;
LogFileOutput("RegLoadValue: %s - %s = ??\n", section, key);
} }
return result;
}
LogFileOutput("RegLoadValue: %s - %s = %d\n", section, key, *value); BOOL RegLoadValue (LPCTSTR section, LPCTSTR key, BOOL peruser, BOOL *value)
{
BOOL result;
try
{
*value = Configuration::instance->getValue<BOOL>(section, key);
result = TRUE;
LogFileOutput("RegLoadValue: %s - %s = %d\n", section, key, *value);
}
catch (const std::exception & e)
{
result = FALSE;
LogFileOutput("RegLoadValue: %s - %s = ??\n", section, key);
}
return result; return result;
} }

View file

@ -182,19 +182,18 @@ void LoadConfiguration(void)
#endif #endif
REGLOAD(TEXT(REGVALUE_EMULATION_SPEED) ,&g_dwSpeed); REGLOAD(TEXT(REGVALUE_EMULATION_SPEED) ,&g_dwSpeed);
DWORD dwTmp; REGLOAD(TEXT(REGVALUE_ENHANCE_DISK_SPEED), &enhancedisk);
REGLOAD(TEXT(REGVALUE_ENHANCE_DISK_SPEED), &dwTmp);
enhancedisk = dwTmp;
#if 0 #if 0
Config_Load_Video(); Config_Load_Video();
REGLOAD(TEXT("Uthernet Active"), &dwTmp); REGLOAD(TEXT("Uthernet Active"), &tfe_enabled);
tfe_enabled = dwTmp;
#endif #endif
SetCurrentCLK6502(); SetCurrentCLK6502();
// //
DWORD dwTmp;
#if 0 #if 0
if(REGLOAD(TEXT(REGVALUE_THE_FREEZES_F8_ROM), &dwTmp)) if(REGLOAD(TEXT(REGVALUE_THE_FREEZES_F8_ROM), &dwTmp))
sg_PropertySheet.SetTheFreezesF8Rom(dwTmp); sg_PropertySheet.SetTheFreezesF8Rom(dwTmp);