gdi32: Avoid integer overflow in the obj map compare fn.

Signed-off-by: Francisco Casas <fcasas@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Francisco Casas 2021-10-27 09:47:06 -03:00 committed by Alexandre Julliard
parent eaa302e6d6
commit d85b700df9
1 changed files with 5 additions and 1 deletions

View File

@ -178,7 +178,11 @@ DWORD WINAPI GetObjectType( HGDIOBJ handle )
static int obj_map_cmp( const void *key, const struct wine_rb_entry *entry )
{
struct obj_map_entry *obj_entry = WINE_RB_ENTRY_VALUE( entry, struct obj_map_entry, entry );
return HandleToLong( key ) - HandleToLong( obj_entry->obj );
UINT_PTR a = (UINT_PTR)key;
UINT_PTR b = (UINT_PTR)obj_entry->obj;
if (a > b) return 1;
if (a < b) return -1;
return 0;
};
struct wine_rb_tree obj_map = { obj_map_cmp };