From: Brendan Shanks <bshanks(a)codeweavers.com> --- dlls/win32u/font.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/dlls/win32u/font.c b/dlls/win32u/font.c index eedc36f8c0d..6551984a54e 100644 --- a/dlls/win32u/font.c +++ b/dlls/win32u/font.c @@ -26,6 +26,7 @@ #include <limits.h> #include <stdarg.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> #include <assert.h> @@ -2311,8 +2312,8 @@ struct font_handle_entry }; static struct font_handle_entry font_handles[MAX_FONT_HANDLES]; -static struct font_handle_entry *next_free; -static struct font_handle_entry *next_unused = font_handles; +static unsigned int next_free = UINT_MAX; +static unsigned int next_unused = 0; static struct font_handle_entry *handle_entry( unsigned int handle ) { @@ -2338,13 +2339,14 @@ static struct gdi_font *get_font_from_handle( unsigned int handle ) static DWORD alloc_font_handle( struct gdi_font *font ) { - struct font_handle_entry *entry; + struct font_handle_entry *entry = NULL; - entry = next_free; + if (next_free != UINT_MAX) + entry = &font_handles[next_free]; if (entry) - next_free = (struct font_handle_entry *)entry->font; - else if (next_unused < font_handles + MAX_FONT_HANDLES) - entry = next_unused++; + next_free = (uintptr_t)entry->font; + else if (next_unused < MAX_FONT_HANDLES) + entry = &font_handles[next_unused++]; else { ERR( "out of realized font handles\n" ); @@ -2361,8 +2363,8 @@ static void free_font_handle( DWORD handle ) if ((entry = handle_entry( handle ))) { - entry->font = (struct gdi_font *)next_free; - next_free = entry; + entry->font = (struct gdi_font *)(uintptr_t)next_free; + next_free = entry - font_handles; } } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7771