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

Alexandre Julliard julliard at winehq.org
Wed Oct 27 16:26:03 CDT 2021


Module: wine
Branch: master
Commit: d85b700df9667e00c1408297da605097ea628d82
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d85b700df9667e00c1408297da605097ea628d82

Author: Francisco Casas <fcasas at codeweavers.com>
Date:   Wed Oct 27 09:47:06 2021 -0300

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

Signed-off-by: Francisco Casas <fcasas at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdi32/objects.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/dlls/gdi32/objects.c b/dlls/gdi32/objects.c
index 4b390aa0160..196cea9ba92 100644
--- a/dlls/gdi32/objects.c
+++ b/dlls/gdi32/objects.c
@@ -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 };




More information about the wine-cvs mailing list