[Spice-devel] [spice-gtk] win-usb: Initialize GError before using it

Christophe Fergeau cfergeau at redhat.com
Thu Sep 4 02:22:05 PDT 2014


GError variables must be set to NULL before passing them to a function
which might set them.
This fixes the runtime warning reported in rhbz#1138195:

(remote-viewer.exe:3896): GLib-WARNING **: GError set over the top of a
previous GError or uninitialized memory.
This indicates a bug in someone's code. You must ensure an error is NULL
before it's set.
The overwriting error message was: handle_dev_change: Error getting
device list from libusb: Other error [-99]
---
 gtk/win-usb-dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gtk/win-usb-dev.c b/gtk/win-usb-dev.c
index 7e82fb9..14ab7af 100644
--- a/gtk/win-usb-dev.c
+++ b/gtk/win-usb-dev.c
@@ -344,7 +344,7 @@ static void handle_dev_change(GUdevClient *self)
     GUdevDevice *changed_dev = NULL;
     ssize_t dev_count;
     int is_dev_change;
-    GError *err;
+    GError *err = NULL;
     GList *now_devs = NULL;
     GList *llist, *slist; /* long-list and short-list*/
     GList *lit, *sit; /* iterators for long-list and short-list */
-- 
1.9.3



More information about the Spice-devel mailing list