[grilo-plugins] lua-factory: Avoid warning if fetching an item failed



commit 2dbe7d4767bbaf76c4d500edb49706fff3464b5f
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Sep 23 14:36:39 2014 +0200

    lua-factory: Avoid warning if fetching an item failed
    
    Before we check whether we have valid UTF-8, best check if fetching
    the item actually worked.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=737169

 src/lua-factory/grl-lua-library.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/src/lua-factory/grl-lua-library.c b/src/lua-factory/grl-lua-library.c
index c88abb7..c48a7a8 100644
--- a/src/lua-factory/grl-lua-library.c
+++ b/src/lua-factory/grl-lua-library.c
@@ -320,9 +320,10 @@ grl_util_fetch_done (GObject *source_object,
   FetchOperation *fo = (FetchOperation *) user_data;
   lua_State *L = fo->L;
 
-  grl_net_wc_request_finish (GRL_NET_WC (source_object),
-                             res, &data, &len, &err);
-  if (!g_utf8_validate(data, len, NULL)) {
+  if (!grl_net_wc_request_finish (GRL_NET_WC (source_object),
+                                  res, &data, &len, &err)) {
+    data = NULL;
+  } else if (!g_utf8_validate(data, len, NULL)) {
     data = NULL;
     g_set_error_literal (&err, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
                          "Fetched item is not valid UTF-8");


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