libsaria: Check stream status before reading

If we are unable to open the preferences file we shouldn't try to read
from it.  This led to a segmentation fault when compiled in release
mode, but for some reason it worked when compiled in debug mode?
This commit is contained in:
Bryan Schumaker 2011-11-09 17:28:19 -05:00
parent 1d704a3ac0
commit 958020f270
1 changed files with 5 additions and 1 deletions

View File

@ -66,8 +66,12 @@ namespace libsaria
void prefs::load()
{
unsigned int size;
InFile in("preferences");
unsigned int size = in.read_ui();
if (!in.good())
return;
size = in.read_ui();
for (unsigned int i = 0; i < size; i++)
load_pref(in);
}