[gnome-software: 1/2] odrs-provider: Check strings aren't null before stripping




commit 933198dcd875119a8a5cda16c33cd1e0dcf5d166
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Tue Mar 1 14:21:09 2022 +0100

    odrs-provider: Check strings aren't null before stripping
    
    This avoids run-time issues.

 lib/gs-odrs-provider.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/lib/gs-odrs-provider.c b/lib/gs-odrs-provider.c
index d110c37e2..3cbb81447 100644
--- a/lib/gs-odrs-provider.c
+++ b/lib/gs-odrs-provider.c
@@ -220,17 +220,20 @@ gs_odrs_provider_parse_review_object (JsonObject *item)
                as_review_set_reviewer_id (rev, json_object_get_string_member (item, "user_hash"));
        if (json_object_has_member (item, "user_display")) {
                g_autofree gchar *user_display = g_strdup (json_object_get_string_member (item, 
"user_display"));
-               g_strstrip (user_display);
+               if (user_display)
+                       g_strstrip (user_display);
                as_review_set_reviewer_name (rev, user_display);
        }
        if (json_object_has_member (item, "summary")) {
                g_autofree gchar *summary = g_strdup (json_object_get_string_member (item, "summary"));
-               g_strstrip (summary);
+               if (summary)
+                       g_strstrip (summary);
                as_review_set_summary (rev, summary);
        }
        if (json_object_has_member (item, "description")) {
                g_autofree gchar *description = g_strdup (json_object_get_string_member (item, 
"description"));
-               g_strstrip (description);
+               if (description)
+                       g_strstrip (description);
                as_review_set_description (rev, description);
        }
        if (json_object_has_member (item, "version"))


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