[recipes] shopping page: Be safe against NULL units
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] shopping page: Be safe against NULL units
- Date: Sat, 14 Jan 2017 19:46:45 +0000 (UTC)
commit ac63763a43223e34f9d432cb4e49d99a08cfc782
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jan 14 14:46:01 2017 -0500
shopping page: Be safe against NULL units
Which happens, e.g. for "6 Eggs".
src/gr-shopping-page.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/src/gr-shopping-page.c b/src/gr-shopping-page.c
index c105601..c1caae6 100644
--- a/src/gr-shopping-page.c
+++ b/src/gr-shopping-page.c
@@ -191,7 +191,7 @@ ingredient_add (Ingredient *ing,
for (i = 0; i < ing->units->len; i++) {
Unit *u = &g_array_index (ing->units, Unit, i);
- if (strcmp (u->unit, unit) == 0) {
+ if (g_strcmp0 (u->unit, unit) == 0) {
gr_number_add (&u->amount, amount, &u->amount);
return;
}
@@ -219,7 +219,8 @@ ingredient_format_unit (Ingredient *ing)
num = gr_number_format (&(u->amount));
g_string_append (s, num);
g_string_append (s, " ");
- g_string_append (s, u->unit);
+ if (u->unit)
+ g_string_append (s, u->unit);
}
return g_strdup (s->str);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]