Skip to content

Commit

Permalink
Fixed bug #187 - Arbitrary memory overwrite occurs when loading glyph…
Browse files Browse the repository at this point in the history
…s and rendering text with a malformed TTF

Pitch/size isn't calculated with 64 bits precisions
  • Loading branch information
1bsyl committed Mar 19, 2022
1 parent 07e224a commit 09a2294
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions SDL_ttf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 09a2294

Please # to comment.