[Spice-devel] [spice-gtk] Do not mix function linkage

Pavel Grunt pgrunt at redhat.com
Tue Jun 7 13:58:27 UTC 2016


Hi,

would you mind adding a comment to the code to avoid the change in the future?

Thanks,
Pavel

On Tue, 2016-06-07 at 12:43 +0100, Frediano Ziglio wrote:
> This prevents a possible crash on windows 32 bit.
> The linkage of UnhookWindowsHookEx is WINAPI which is __stdcall while
> callback for g_clear_pointer is C. This could cause stack pointer
> corruption depending on compiler flags.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  src/spice-widget.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/spice-widget.c b/src/spice-widget.c
> index b5936bc..2f1bb96 100644
> --- a/src/spice-widget.c
> +++ b/src/spice-widget.c
> @@ -827,7 +827,8 @@ static void try_keyboard_ungrab(SpiceDisplay *display)
>      SPICE_DEBUG("ungrab keyboard");
>      gdk_keyboard_ungrab(GDK_CURRENT_TIME);
>  #ifdef G_OS_WIN32
> -    g_clear_pointer(&d->keyboard_hook, UnhookWindowsHookEx);
> +    UnhookWindowsHookEx(d->keyboard_hook);
> +    d->keyboard_hook = NULL;
>  #endif
>      d->keyboard_grab_active = false;
>      g_signal_emit(widget, signals[SPICE_DISPLAY_KEYBOARD_GRAB], 0, false);


More information about the Spice-devel mailing list