diff options
author | Frediano Ziglio <fziglio@redhat.com> | 2016-06-07 12:43:07 +0100 |
---|---|---|
committer | Frediano Ziglio <fziglio@redhat.com> | 2016-06-13 10:19:32 +0100 |
commit | 99f357d6a544717547c75304ffc33608a6b07d07 (patch) | |
tree | 1f5d5eb92d27790d3486405a150f77a0ce687d5b /src | |
parent | 3e08aef2d30580b32e4024bcdc9d8a95dcccea87 (diff) |
widget: Do not mix function linkage
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.
On __stdcall linkage function change the stack pointer while returning
from a function removing the parameters. On C linkage function leave
the stack pointer unchanged. So if the compiler call a __stdcall
function as a C function it expect the stack pointer to be unchanged
causing the pointer to be inconsistent by an offset.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/spice-widget.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/spice-widget.c b/src/spice-widget.c index b5936bc..c528614 100644 --- a/src/spice-widget.c +++ b/src/spice-widget.c @@ -827,7 +827,11 @@ 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); + // do not use g_clear_pointer as Windows API have different linkage + if (d->keyboard_hook) { + 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); |