Merge pull request #12153 from akallabeth/fix-fix-fix

Double free fixes
This commit is contained in:
akallabeth
2026-01-19 09:17:58 +01:00
committed by GitHub
2 changed files with 11 additions and 9 deletions

View File

@@ -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

View File

@@ -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;
}