From: Brendan Shanks bshanks@codeweavers.com
--- dlls/win32u/font.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/dlls/win32u/font.c b/dlls/win32u/font.c index 7d7aa26adc7..e782426d51b 100644 --- a/dlls/win32u/font.c +++ b/dlls/win32u/font.c @@ -2311,8 +2311,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 +2338,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 +2362,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; } }