If viking.prefs is empty this triggers the following warning at startup in 
valgrind:

==21725== Conditional jump or move depends on uninitialised value(s)
==21725==    at 0x447354: preferences_load_from_file (preferences.c:147)
==21725==    by 0x447444: a_preferences_get (preferences.c:318)
==21725==    by 0x41019D: a_vik_get_default_lat (globals.c:133)
==21725==    by 0x42B6F3: viewport_init (vikviewport.c:167)
...

This occurs when fgets() returns NULL but the code still tries to
interpret the uninitialized contents of buf.

  Jon

---
 src/preferences.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/preferences.c b/src/preferences.c
index 65cacc5..386f667 100644
--- a/src/preferences.c
+++ b/src/preferences.c
@@ -169,7 +169,8 @@ static gboolean preferences_load_from_file()
     gchar *key, *val;
     VikLayerTypedParamData *oldval, *newval;
     while ( ! feof (f) ) {
-      fgets(buf,sizeof(buf),f);
+      if (fgets(buf,sizeof(buf),f) == NULL)
+        break;
       if ( preferences_load_parse_param(buf, &key, &val ) ) {
         // if it's not in there, ignore it
         oldval = g_hash_table_lookup ( values, key );
-- 
1.7.2.3



------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Viking-devel mailing list
Viking-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/viking-devel
Viking home page: http://viking.sf.net/

Reply via email to