From 958020f270b29844127f2270323ce37703a175bd Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Wed, 9 Nov 2011 17:28:19 -0500 Subject: [PATCH] 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? --- libsaria/prefs.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libsaria/prefs.cpp b/libsaria/prefs.cpp index fafe5f29..5e3ba3ff 100644 --- a/libsaria/prefs.cpp +++ b/libsaria/prefs.cpp @@ -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); }