diff --git a/gdk/win32/gdkselection-win32.c b/gdk/win32/gdkselection-win32.c index 8c54240782..2bb7ffd7c8 100644 --- a/gdk/win32/gdkselection-win32.c +++ b/gdk/win32/gdkselection-win32.c @@ -1285,12 +1285,15 @@ _gdk_win32_selection_convert_to_dib (HGLOBAL hdata, if (target == _image_bmp) { + HGLOBAL hdatanew; + SIZE_T size; + guchar *ptr; + g_return_val_if_fail (GlobalSize (hdata) >= sizeof (BITMAPFILEHEADER), NULL); /* No conversion is needed, just strip the BITMAPFILEHEADER */ - HGLOBAL hdatanew; - SIZE_T size = GlobalSize (hdata) - sizeof (BITMAPFILEHEADER); - guchar *ptr = GlobalLock (hdata); + size = GlobalSize (hdata) - sizeof (BITMAPFILEHEADER); + ptr = GlobalLock (hdata); memmove (ptr, ptr + sizeof (BITMAPFILEHEADER), size); GlobalUnlock (hdata);