[Spice-devel] [PATCH spice-gtk 1/2] Be more tolerant on NULL arrays
Marc-André Lureau
marcandre.lureau at gmail.com
Thu Mar 29 12:32:17 PDT 2012
2 places where we should be more carreful with NULL arrays, and we can
avoid potential crashes.
---
gtk/spice-session.c | 3 ++-
gtk/usb-device-widget.c | 3 +++
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index e9c8b94..ea1a0f3 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -474,7 +474,8 @@ static void spice_session_set_property(GObject *gobject,
s->client_provided_sockets = g_value_get_boolean(value);
break;
case PROP_PUBKEY:
- g_byte_array_unref(s->pubkey);
+ if (s->pubkey)
+ g_byte_array_unref(s->pubkey);
s->pubkey = g_value_get_boxed(value);
if (s->pubkey)
s->verify = SPICE_SESSION_VERIFY_PUBKEY;
diff --git a/gtk/usb-device-widget.c b/gtk/usb-device-widget.c
index 8501ab4..64c4a72 100644
--- a/gtk/usb-device-widget.c
+++ b/gtk/usb-device-widget.c
@@ -219,12 +219,15 @@ static GObject *spice_usb_device_widget_constructor(
G_CALLBACK(device_error_cb), self);
devices = spice_usb_device_manager_get_devices(priv->manager);
+ if (!devices)
+ goto end;
for (i = 0; i < devices->len; i++)
device_added_cb(NULL, g_ptr_array_index(devices, i), self);
g_ptr_array_unref(devices);
+end:
return obj;
}
--
1.7.7.6
More information about the Spice-devel
mailing list