From 09a2294338d7907ae955b07affdac229546f9cc9 Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Sat, 19 Mar 2022 16:17:23 +0100
Subject: [PATCH] Fixed bug #187 - Arbitrary memory overwrite occurs when
loading glyphs and rendering text with a malformed TTF Pitch/size isn't
calculated with 64 bits precisions
---
SDL_ttf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/SDL_ttf.c b/SDL_ttf.c
index 053f42b..1c19458 100644
--- a/SDL_ttf.c
+++ b/SDL_ttf.c
@@ -1257,7 +1257,7 @@ static SDL_Surface* Create_Surface_Solid(int width, int height, SDL_Color fg, Ui
*/
void *pixels, *ptr;
/* Worse case at the end of line pulling 'alignment' extra blank pixels */
- int pitch = width + alignment;
+ Sint64 pitch = width + alignment;
pitch += alignment;
pitch &= ~alignment;
size = height * pitch + sizeof (void *) + alignment;
@@ -1321,7 +1321,7 @@ static SDL_Surface* Create_Surface_Shaded(int width, int height, SDL_Color fg, S
*/
void *pixels, *ptr;
/* Worse case at the end of line pulling 'alignment' extra blank pixels */
- int pitch = width + alignment;
+ Sint64 pitch = width + alignment;
pitch += alignment;
pitch &= ~alignment;
size = height * pitch + sizeof (void *) + alignment;
@@ -1418,7 +1418,7 @@ static SDL_Surface *Create_Surface_Blended(int width, int height, SDL_Color fg,
Sint64 size;
void *pixels, *ptr;
/* Worse case at the end of line pulling 'alignment' extra blank pixels */
- int pitch = (width + alignment) * 4;
+ Sint64 pitch = (width + alignment) * 4;
pitch += alignment;
pitch &= ~alignment;
size = height * pitch + sizeof (void *) + alignment;