]> git.street.me.uk Git - andy/viking.git/commitdiff
Coverity: Prevent deference after null checks
authorRob Norris <rw_norris@hotmail.com>
Fri, 13 Nov 2015 22:00:52 +0000 (22:00 +0000)
committerRob Norris <rw_norris@hotmail.com>
Sat, 14 Nov 2015 10:27:30 +0000 (10:27 +0000)
CID#34580
CID#34582
CID#34588
CID#34589

src/settings.c
src/vikmapslayer.c
src/vikutils.c

index 09d99f9b1ed843a8756031c302df159ef75f671d..e3b1c1d584c465be0c5269c0e3fad5008c5f4d7f 100644 (file)
@@ -255,13 +255,13 @@ gboolean a_settings_get_integer_list_contains ( const gchar *name, gint val )
 void a_settings_set_integer_list_containing ( const gchar *name, gint val )
 {
        gint* vals = NULL;
-       gsize length;
+       gsize length = 0;
        gboolean need_to_add = TRUE;
        gint ii = 0;
        // Get current list
        if ( a_settings_get_integer_list ( name, &vals, &length ) ) {
                // See if it's not already there
-               if ( vals && length ) {
+               if ( vals ) {
                        while ( ii < length ) {
                                if ( vals[ii] == val ) {
                                        need_to_add = FALSE;
@@ -272,7 +272,7 @@ void a_settings_set_integer_list_containing ( const gchar *name, gint val )
                }
        }
        // Add value into array if necessary
-       if ( need_to_add ) {
+       if ( vals && need_to_add ) {
                // NB not bothering to sort this 'list' ATM as there is not much to be gained
                guint new_length = length + 1;
                gint new_vals[new_length];
index d52b2c01457a51b2167a548f62c38d8f6b4916b6..624e8a3490982557cfc50f5150dde48b3beeac3f 100644 (file)
@@ -679,15 +679,15 @@ static VikLayerParamData maps_layer_get_param ( VikMapsLayer *vml, guint16 id, g
         rv.s = "";
         set = TRUE;
       }
-      else if ( is_file_operation ) {
+      else if ( is_file_operation && vml->cache_dir ) {
         if ( a_vik_get_file_ref_format() == VIK_FILE_REF_FORMAT_RELATIVE ) {
           gchar *cwd = g_get_current_dir();
           if ( cwd ) {
             rv.s = file_GetRelativeFilename ( cwd, vml->cache_dir );
             if ( !rv.s ) rv.s = "";
             set = TRUE;
-         }
-       }
+          }
+        }
       }
       if ( !set )
        rv.s = vml->cache_dir ? vml->cache_dir : "";
@@ -946,7 +946,7 @@ static GdkPixbuf *get_pixbuf_sql_exec ( sqlite3 *sql, gint xx, gint yy, gint zoo
             GInputStream *stream = g_memory_input_stream_new_from_data ( data, bytes, NULL );
             GError *error = NULL;
             pixbuf = gdk_pixbuf_new_from_stream ( stream, NULL, &error );
-            if (error || (!pixbuf)) {
+            if ( error ) {
               g_warning ( "%s: %s", __FUNCTION__, error->message );
               g_error_free ( error );
             }
index e90efb4a1121f6da84a17bc2ee074b2f50674226..db75aa9ace7f30dcb72d5b76fa5f8d1d869b5c53 100644 (file)
@@ -318,7 +318,8 @@ gchar* vu_trackpoint_formatted_message ( gchar *format_code, VikTrackpoint *trkp
                }
 
                case 'N': // Name of track
-                       values[i] = g_strdup_printf ( _("%sTrack: %s"), separator, trk->name );
+                       if ( trk )
+                               values[i] = g_strdup_printf ( _("%sTrack: %s"), separator, trk->name );
                        break;
 
                case 'E': // Name of trackpoint if available