[recipes] Be more careful about NULL strings



commit 3a95a45dfa2d502c07d505d04eb91afe1d5d35c1
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Feb 22 09:31:33 2017 -0500

    Be more careful about NULL strings
    
    Strings coming from recipe objects may be NULL,
    we should be careful about that when comparing them.

 src/gr-recipe-store.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/gr-recipe-store.c b/src/gr-recipe-store.c
index 75f90da..d44fb99 100644
--- a/src/gr-recipe-store.c
+++ b/src/gr-recipe-store.c
@@ -379,7 +379,7 @@ load_recipes (GrRecipeStore *self,
                 else {
                         gboolean own;
 
-                        own = strcmp (author, self->user) == 0;
+                        own = g_strcmp0 (author, self->user) == 0;
                         recipe = g_object_new (GR_TYPE_RECIPE,
                                                "id", id,
                                                "name", name,
@@ -1595,7 +1595,7 @@ gr_recipe_store_has_chef (GrRecipeStore *self,
 
         g_hash_table_iter_init (&iter, self->recipes);
         while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&recipe)) {
-                if (strcmp (gr_chef_get_id (chef), gr_recipe_get_author (recipe)) == 0)
+                if (g_strcmp0 (gr_chef_get_id (chef), gr_recipe_get_author (recipe)) == 0)
                         return TRUE;
         }
 
@@ -1611,7 +1611,7 @@ gr_recipe_store_has_cuisine (GrRecipeStore *self,
 
         g_hash_table_iter_init (&iter, self->recipes);
         while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&recipe)) {
-                if (strcmp (cuisine, gr_recipe_get_cuisine (recipe)) == 0)
+                if (g_strcmp0 (cuisine, gr_recipe_get_cuisine (recipe)) == 0)
                         return TRUE;
         }
 


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