[epiphany] gsb-utils: Handle missing firstValue in RiceDeltaEncoding object
- From: Gabriel Ivașcu <gabrielivascu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] gsb-utils: Handle missing firstValue in RiceDeltaEncoding object
- Date: Sat, 27 Jan 2018 11:51:36 +0000 (UTC)
commit eccbca238a41115e01845534add6db5f27da63b1
Author: Gabriel Ivascu <gabrielivascu gnome org>
Date: Sat Jan 27 01:09:20 2018 +0200
gsb-utils: Handle missing firstValue in RiceDeltaEncoding object
https://bugzilla.gnome.org/show_bug.cgi?id=792930
lib/safe-browsing/ephy-gsb-utils.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/lib/safe-browsing/ephy-gsb-utils.c b/lib/safe-browsing/ephy-gsb-utils.c
index 62823a5..e448c7b 100644
--- a/lib/safe-browsing/ephy-gsb-utils.c
+++ b/lib/safe-browsing/ephy-gsb-utils.c
@@ -467,7 +467,7 @@ ephy_gsb_utils_rice_delta_decode (JsonObject *rde,
{
EphyGSBRiceDecoder *decoder;
const char *data_b64 = NULL;
- const char *first_value_str;
+ const char *first_value_str = NULL;
guint32 *items;
guint8 *data;
gsize data_len;
@@ -477,9 +477,8 @@ ephy_gsb_utils_rice_delta_decode (JsonObject *rde,
g_assert (rde);
g_assert (num_items);
- /* This field is never missing. */
- first_value_str = json_object_get_string_member (rde, "firstValue");
-
+ if (json_object_has_member (rde, "firstValue"))
+ first_value_str = json_object_get_string_member (rde, "firstValue");
if (json_object_has_member (rde, "riceParameter"))
parameter = json_object_get_int_member (rde, "riceParameter");
if (json_object_has_member (rde, "numEntries"))
@@ -489,7 +488,7 @@ ephy_gsb_utils_rice_delta_decode (JsonObject *rde,
*num_items = 1 + num_entries;
items = g_malloc (*num_items * sizeof (guint32));
- items[0] = g_ascii_strtoull (first_value_str, NULL, 10);
+ items[0] = first_value_str ? g_ascii_strtoull (first_value_str, NULL, 10) : 0;
if (num_entries == 0)
return items;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]