[libshumate] license: Handle null license text



commit b4e96a2ee4c35a63b6c33b12396c1867faca2668
Author: James Westman <james jwestman net>
Date:   Fri Aug 20 00:44:10 2021 -0500

    license: Handle null license text
    
    Some map sources (like the test one in the demo) don't have license
    text.

 shumate/shumate-license.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/shumate/shumate-license.c b/shumate/shumate-license.c
index e0ddc55..2a7b541 100644
--- a/shumate/shumate-license.c
+++ b/shumate/shumate-license.c
@@ -107,10 +107,15 @@ shumate_license_sources_changed (ShumateLicense *self)
   for (i = 0; i < self->map_sources->len; i++)
     {
       ShumateMapSource *map_source = g_ptr_array_index (self->map_sources, i);
-      if (i == 0)
-        g_string_append (license_str, shumate_map_source_get_license (map_source));
+      const char *license = shumate_map_source_get_license (map_source);
+
+      if (license == NULL)
+        continue;
+
+      if (license_str->len == 0)
+        g_string_append (license_str, license);
       else
-        g_string_append_printf (license_str, "\n%s", shumate_map_source_get_license (map_source));
+        g_string_append_printf (license_str, "\n%s", license);
     }
 
   gtk_label_set_label (GTK_LABEL (self->license_label), license_str->str);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]