Re: [spice-gtk][PATCH] spice-widget: Don't crash when Display is NULL

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

 



On Mon, Nov 24, 2014 at 4:28 PM, Christophe Fergeau <cfergeau@xxxxxxxxxx> wrote:
> On Mon, Nov 24, 2014 at 01:25:51AM +0100, Fabiano Fidêncio wrote:
>> Return early or warn when SpiceDisplay is NULL instead of crash, avoiding
>> segfaults when running on windows using GTK3
>> ---
>>  gtk/spice-widget.c | 16 +++++++++++++---
>>  1 file changed, 13 insertions(+), 3 deletions(-)
>>
>> diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
>> index ae11073..67429f0 100644
>> --- a/gtk/spice-widget.c
>> +++ b/gtk/spice-widget.c
>> @@ -701,9 +701,12 @@ SpiceGrabSequence *spice_display_get_grab_keys(SpiceDisplay *display)
>>  static void try_keyboard_grab(SpiceDisplay *display)
>>  {
>>      GtkWidget *widget = GTK_WIDGET(display);
>> +    GdkWindow *window = gtk_widget_get_window(widget);
>>      SpiceDisplayPrivate *d = display->priv;
>>      GdkGrabStatus status;
>>
>> +    g_return_if_fail(window != NULL);
>> +
>>      if (g_getenv("SPICE_NOGRAB"))
>>          return;
>>      if (d->disable_inputs)
>> @@ -731,8 +734,8 @@ static void try_keyboard_grab(SpiceDisplay *display)
>>                                              GetModuleHandle(NULL), 0);
>>      g_warn_if_fail(d->keyboard_hook != NULL);
>>  #endif
>> -    status = gdk_keyboard_grab(gtk_widget_get_window(widget), FALSE,
>> -                               GDK_CURRENT_TIME);
>> +
>> +    status = gdk_keyboard_grab(window, FALSE, GDK_CURRENT_TIME);
>>      if (status != GDK_GRAB_SUCCESS) {
>>          g_warning("keyboard grab failed %d", status);
>>          d->keyboard_grab_active = false;
>> @@ -1294,7 +1297,14 @@ static gboolean check_for_grab_key(SpiceDisplay *display, int type, int keyval)
>>  static void update_display(SpiceDisplay *display)
>>  {
>>  #ifdef G_OS_WIN32
>> -    win32_window = display ? GDK_WINDOW_HWND(gtk_widget_get_window(GTK_WIDGET(display))) : NULL;
>> +    GdkWindow *window = NULL;
>> +
>> +    if (display != NULL) {
>> +        window = gtk_widget_get_window(GTK_WIDGET(display));
>> +        g_warn_if_fail (window != NULL);
>> +    }
>> +
>> +    win32_window = window ? GDK_WINDOW_HWND(window) : NULL;
>>  #endif
>
> For what it's worth, this hunk seems to be more about protecting against
> a NULL window (which could come from
> gtk_widget_get_window(GTK_WIDGET(NULL))) than protecting against a NULL
> display.
>

 I see your point. Would be better a different patch for this part.

Best Regards,
-- 
Fabiano Fidêncio
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]