[discident-glib] lib: Fail when the response is empty
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [discident-glib] lib: Fail when the response is empty
- Date: Tue, 2 Apr 2013 13:49:33 +0000 (UTC)
commit d384aa9b6139786da030b64958f7c33cd56f694c
Author: Bastien Nocera <hadess hadess net>
Date: Tue Apr 2 15:41:52 2013 +0200
lib: Fail when the response is empty
discident-glib/discident-ean-glib.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/discident-glib/discident-ean-glib.c b/discident-glib/discident-ean-glib.c
index b08588f..0cf8e42 100644
--- a/discident-glib/discident-ean-glib.c
+++ b/discident-glib/discident-ean-glib.c
@@ -232,9 +232,9 @@ uncompress (const char *data,
}
static gboolean
-parse_lookup_response (const char *response,
- char **ret_title,
- char **ret_img_url)
+parse_lookup_response (const char *response,
+ char **ret_title,
+ char **ret_img_url)
{
xmlDocPtr doc;
xmlChar *title, *img_url;
@@ -345,10 +345,17 @@ discident_ean_lookup_sync (DiscidentEan *ean,
}
if (parse_lookup_response (response, title, img_url) == FALSE) {
+ g_free (response);
g_set_error (error, DISCIDENT_ERROR, DISCIDENT_ERROR_PARSE, "Failed to parse response from
EAN service");
return FALSE;
}
+ if (g_strcmp0 (*title, barcode) == 0) {
+ g_free (response);
+ g_set_error (error, DISCIDENT_ERROR, DISCIDENT_ERROR_EMPTY_RESPONSE, "No response for
requested barcode");
+ return FALSE;
+ }
+
g_free (response);
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]