]> git.street.me.uk Git - andy/viking.git/commitdiff
Coverity: Fix deference after null checks
authorRob Norris <rw_norris@hotmail.com>
Thu, 12 Nov 2015 22:35:20 +0000 (22:35 +0000)
committerRob Norris <rw_norris@hotmail.com>
Sat, 14 Nov 2015 10:26:40 +0000 (10:26 +0000)
CID#34585
CID#34590
CID#34591

src/download.c
src/gpspoint.c

index 328f60c695ce23293506902a6b287878f9e3736f..ccb4cff5bf8cd614ea0cb4975fa90b95780d0090 100644 (file)
@@ -287,10 +287,10 @@ static DownloadResult_t download( const char *hostname, const char *uri, const c
       return DOWNLOAD_NOT_REQUIRED;
     }
 
-    if (options->check_file_server_time) {
+    if (options != NULL && options->check_file_server_time) {
       file_options.time_condition = file_time;
     }
-    if (options->use_etag) {
+    if (options != NULL && options->use_etag) {
       gchar *etag_filename = g_strdup_printf("%s.etag", fn);
       gsize etag_length = 0;
       g_file_get_contents (etag_filename, &(file_options.etag), &etag_length, NULL);
@@ -357,17 +357,17 @@ static DownloadResult_t download( const char *hostname, const char *uri, const c
     g_remove ( tmpfilename );
     unlock_file ( tmpfilename );
     g_free ( tmpfilename );
-    if (options->use_etag) {
+    if ( options != NULL && options->use_etag ) {
       g_free ( file_options.etag );
       g_free ( file_options.new_etag );
     }
     return result;
   }
 
-  if ( options->convert_file )
-         options->convert_file ( tmpfilename );
+  if ( options != NULL && options->convert_file )
+    options->convert_file ( tmpfilename );
 
-  if (options->use_etag) {
+  if ( options != NULL && options->use_etag ) {
     if (file_options.new_etag) {
       /* server returned an etag value */
       gchar *etag_filename = g_strdup_printf("%s.etag", fn);
@@ -392,7 +392,7 @@ static DownloadResult_t download( const char *hostname, const char *uri, const c
   unlock_file ( tmpfilename );
   g_free ( tmpfilename );
 
-  if (options->use_etag) {
+  if ( options != NULL && options->use_etag ) {
     g_free ( file_options.etag );
     g_free ( file_options.new_etag );
   }
index bee2d337a26fbaf408ff2a9e0546957154402aab..b899b28d6e3e1a0c8626d71eed408290b6d901fe 100644 (file)
@@ -463,7 +463,7 @@ static void gpspoint_process_key_and_value ( const gchar *key, gint key_len, con
   {
     line_altitude = g_ascii_strtod(value, NULL);
   }
-  else if (key_len == 7 && strncasecmp( key, "visible", key_len ) == 0 && value[0] != 'y' && value[0] != 'Y' && value[0] != 't' && value[0] != 'T')
+  else if (key_len == 7 && strncasecmp( key, "visible", key_len ) == 0 && value != NULL && value[0] != 'y' && value[0] != 'Y' && value[0] != 't' && value[0] != 'T')
   {
     line_visible = FALSE;
   }
@@ -507,10 +507,12 @@ static void a_gpspoint_write_waypoint ( const gpointer id, const VikWaypoint *wp
 {
   static struct LatLon ll;
   gchar *s_lat, *s_lon;
-  // Sanity clause
-  if ( wp && !(wp->name) ) {
+  // Sanity clauses
+  if ( !wp )
     return;
-  }
+  if ( !(wp->name) )
+    return;
+
   vik_coord_to_latlon ( &(wp->coord), &ll );
   s_lat = a_coords_dtostr(ll.lat);
   s_lon = a_coords_dtostr(ll.lon);