[grilo-plugins] lua-factory: fix crash on error



commit c30ada523fd662ad5e20027ea168071fc604d70c
Author: Victor Toso <me victortoso com>
Date:   Thu Apr 28 22:51:54 2016 +0200

    lua-factory: fix crash on error
    
    On grl_net_wc_request_async callback, we could be using the GError
    pointer more then once in the function, which leads to non null value.
    
    This patch clears the GError pointer and add guards to
    grl_lua_operations_pcall.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764814

 src/lua-factory/grl-lua-library-operations.c |    2 ++
 src/lua-factory/grl-lua-library.c            |    4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/lua-factory/grl-lua-library-operations.c b/src/lua-factory/grl-lua-library-operations.c
index 0fa6a9d..7b0397a 100644
--- a/src/lua-factory/grl-lua-library-operations.c
+++ b/src/lua-factory/grl-lua-library-operations.c
@@ -687,6 +687,8 @@ grl_lua_operations_pcall (lua_State *L,
                           GError **err)
 {
   g_assert_nonnull (os);
+  g_assert_nonnull (err);
+  g_assert_null (*err);
 
   GRL_DEBUG ("%s | %s (op-id: %u)", __func__,
              grl_source_get_id (os->source),
diff --git a/src/lua-factory/grl-lua-library.c b/src/lua-factory/grl-lua-library.c
index 1952f15..65a3314 100644
--- a/src/lua-factory/grl-lua-library.c
+++ b/src/lua-factory/grl-lua-library.c
@@ -494,7 +494,7 @@ grl_util_fetch_done (GObject *source_object,
 
   if (err != NULL) {
     GRL_WARNING ("Can't fetch element %d (URL: %s): '%s'", fo->index + 1, fo->url, err->message);
-    g_error_free (err);
+    g_clear_error (&err);
   } else {
     GRL_DEBUG ("fetch_done element %d of %d urls", fo->index + 1, fo->num_urls);
   }
@@ -530,7 +530,7 @@ grl_util_fetch_done (GObject *source_object,
   if (!grl_lua_operations_pcall (L, 2, os, &err)) {
     if (err != NULL) {
       GRL_WARNING ("calling source callback function fail: %s", err->message);
-      g_error_free (err);
+      g_clear_error (&err);
     }
   }
 


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