From c8553b7cbe24e932756cbf40419df17474d10926 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Mon, 9 May 2022 19:28:52 +0100
Subject: [PATCH] Use 64-bit arithmetic in Create_Surface_LCD
This catches up with commits 09a2294 "Fixed bug #187 - Arbitrary memory
overwrite occurs when loading glyphs and rendering text with a
malformed TTF" and db1b41a "More integer overflow (see bug #187)"
in code that was written before those fixes, but merged after them.
Fixes: f26fa4c "Add functions to use FreeType ClearType-style LCD rendering (#138)"
Signed-off-by: Simon McVittie <smcv@collabora.com>
---
SDL_ttf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/SDL_ttf.c b/SDL_ttf.c
index 215a63b..e9c3f00 100644
--- a/SDL_ttf.c
+++ b/SDL_ttf.c
@@ -1600,7 +1600,7 @@ static SDL_Surface* Create_Surface_LCD(int width, int height, SDL_Color fg, SDL_
Sint64 size;
void *pixels, *ptr;
/* Worse case at the end of line pulling 'alignment' extra blank pixels */
- int pitch = (width + alignment) * 4;
+ Sint64 pitch = ((Sint64)width + (Sint64)alignment) * 4;
pitch += alignment;
pitch &= ~alignment;
size = height * pitch + sizeof (void *) + alignment;