diff --git a/client/X11/xf_graphics.c b/client/X11/xf_graphics.c index df95a22b5..9d432c98b 100644 --- a/client/X11/xf_graphics.c +++ b/client/X11/xf_graphics.c @@ -289,7 +289,6 @@ static BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer) #ifdef WITH_XCURSOR UINT32 CursorFormat = 0; - size_t size = 0; xfContext* xfc = (xfContext*)context; xfPointer* xpointer = (xfPointer*)pointer; @@ -304,19 +303,18 @@ static BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer) xpointer->nCursors = 0; xpointer->mCursors = 0; - size = 1ull * pointer->height * pointer->width * FreeRDPGetBytesPerPixel(CursorFormat); + const size_t size = + 1ull * pointer->height * pointer->width * FreeRDPGetBytesPerPixel(CursorFormat); - if (!(xpointer->cursorPixels = (XcursorPixel*)winpr_aligned_malloc(size, 16))) + xpointer->cursorPixels = (XcursorPixel*)winpr_aligned_malloc(size, 16); + if (!xpointer->cursorPixels) goto fail; if (!freerdp_image_copy_from_pointer_data( (BYTE*)xpointer->cursorPixels, CursorFormat, 0, 0, 0, pointer->width, pointer->height, pointer->xorMaskData, pointer->lengthXorMask, pointer->andMaskData, pointer->lengthAndMask, pointer->xorBpp, &context->gdi->palette)) - { - winpr_aligned_free(xpointer->cursorPixels); goto fail; - } #endif diff --git a/libfreerdp/cache/offscreen.c b/libfreerdp/cache/offscreen.c index 91fa38f32..d3c85f95d 100644 --- a/libfreerdp/cache/offscreen.c +++ b/libfreerdp/cache/offscreen.c @@ -164,8 +164,6 @@ void offscreen_cache_put(rdpOffscreenCache* offscreenCache, UINT32 index, rdpBit void offscreen_cache_delete(rdpOffscreenCache* offscreenCache, UINT32 index) { - rdpBitmap* prevBitmap = NULL; - WINPR_ASSERT(offscreenCache); if (index >= offscreenCache->maxEntries) @@ -174,10 +172,16 @@ void offscreen_cache_delete(rdpOffscreenCache* offscreenCache, UINT32 index) return; } - prevBitmap = offscreenCache->entries[index]; + rdpBitmap* prevBitmap = offscreenCache->entries[index]; if (prevBitmap != NULL) + { + WINPR_ASSERT(offscreenCache->context); + + /* Ensure that the bitmap is no longer used in GDI */ + IFCALL(prevBitmap->SetSurface, offscreenCache->context, NULL, FALSE); Bitmap_Free(offscreenCache->context, prevBitmap); + } offscreenCache->entries[index] = NULL; }