[Spice-devel] [PATCH 1/4] gtk: warn if argument is invalid instead of crash

Marc-André Lureau marcandre.lureau at gmail.com
Wed Oct 19 02:29:27 PDT 2011


---
 gtk/spice-widget.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
index afe030d..fa7f675 100644
--- a/gtk/spice-widget.c
+++ b/gtk/spice-widget.c
@@ -675,6 +675,7 @@ static gboolean draw_event(GtkWidget *widget, cairo_t *cr)
 {
     SpiceDisplay *display = SPICE_DISPLAY(widget);
     SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+    g_return_val_if_fail(d != NULL, false);
 
     if (d->mark == 0 || d->data == NULL)
         return false;
@@ -692,6 +693,7 @@ static gboolean expose_event(GtkWidget *widget, GdkEventExpose *expose)
 {
     SpiceDisplay *display = SPICE_DISPLAY(widget);
     SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+    g_return_val_if_fail(d != NULL, false);
 
     if (d->mark == 0 || d->data == NULL)
         return false;
@@ -1349,6 +1351,7 @@ static void mark(SpiceChannel *channel, gint mark, gpointer data)
 {
     SpiceDisplay *display = data;
     SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
+    g_return_if_fail(d != NULL);
 
     SPICE_DEBUG("widget mark: %d, channel %d", mark, d->channel_id);
     d->mark = mark;
-- 
1.7.6.2



More information about the Spice-devel mailing list