Commit 220b0a7c authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

win32u: Do not free user memory when deleting dibs created with NtGdiDdDDICreateDCFromMemory().

This fixes a test crash in ddraw:ddraw1 introduced by 7d2a7b94. Signed-off-by: 's avatarZebediah Figura <zfigura@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent c1ed24c8
......@@ -5969,11 +5969,11 @@ static void test_D3DKMTCreateDCFromMemory( void )
size = VirtualQuery( alloc_data, &memory_info, sizeof(memory_info) );
ok(size == sizeof(memory_info), "Got unexpected size %u.\n", size);
todo_wine ok(memory_info.State == MEM_COMMIT, "Got state %#x.\n", memory_info.State);
todo_wine ok(memory_info.Protect == PAGE_READWRITE, "Got protection %#x.\n", memory_info.Protect);
ok(memory_info.State == MEM_COMMIT, "Got state %#x.\n", memory_info.State);
ok(memory_info.Protect == PAGE_READWRITE, "Got protection %#x.\n", memory_info.Protect);
ret = VirtualFree( alloc_data, 0, MEM_RELEASE );
todo_wine ok(ret, "Failed to free memory, error %u.\n", GetLastError());
ok(ret, "Failed to free memory, error %u.\n", GetLastError());
}
START_TEST(bitmap)
......
......@@ -1574,6 +1574,24 @@ error:
}
static BOOL memory_dib_DeleteObject( HGDIOBJ handle )
{
BITMAPOBJ *bmp;
if (!(bmp = free_gdi_handle( handle ))) return FALSE;
free( bmp->color_table );
free( bmp );
return TRUE;
}
static const struct gdi_obj_funcs memory_dib_funcs =
{
.pGetObjectW = DIB_GetObject,
.pDeleteObject = memory_dib_DeleteObject,
};
/***********************************************************************
* NtGdiDdDDICreateDCFromMemory (win32u.@)
*/
......@@ -1673,7 +1691,7 @@ NTSTATUS WINAPI NtGdiDdDDICreateDCFromMemory( D3DKMT_CREATEDCFROMMEMORY *desc )
}
}
if (!(bitmap = alloc_gdi_handle( &bmp->obj, NTGDI_OBJ_BITMAP, &dib_funcs ))) goto error;
if (!(bitmap = alloc_gdi_handle( &bmp->obj, NTGDI_OBJ_BITMAP, &memory_dib_funcs ))) goto error;
desc->hDc = dc;
desc->hBitmap = bitmap;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment