Fixed to safely sscanf.

This commit is contained in:
Kelvin Lee 2016-09-10 10:17:41 +10:00 committed by tomcw
parent 9ec4012209
commit 03996c45a8

View File

@ -1114,13 +1114,19 @@ bool CAY8910::LoadSnapshot(YamlLoadHelper& yamlLoadHelper, std::string& suffix)
if (!bFound)
break; // done
int _tstates = 0;
int _ofs = 0;
unsigned int _reg = 0;
unsigned int _val = 0;
if(4 != sscanf_s(value.c_str(), SS_YAML_VALUE_CHANGE_FORMAT,
&ay_change[ay_change_count].tstates,
&ay_change[ay_change_count].ofs,
&ay_change[ay_change_count].reg,
&ay_change[ay_change_count].val))
&_tstates, &_ofs, &_reg, &_val))
throw std::string("Card: AY8910: Failed to scanf change list");
ay_change[ay_change_count].tstates = _tstates;
ay_change[ay_change_count].ofs = _ofs;
ay_change[ay_change_count].reg = _reg;
ay_change[ay_change_count].val = _val;
ay_change_count++;
if (ay_change_count > AY_CHANGE_MAX)
throw std::string("Card: AY8910: Too many changes");