Skip to content

Commit bb85549

Browse files
1bsylslouken
authored andcommitted
Fixed bug #537 - prevent incrementing a null pointer 'image->buffer',
which would be detected by UBsan sanitizer. (cherry picked from commit 7930c02)
1 parent a96c9a1 commit bb85549

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

SDL_ttf.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,11 +1158,16 @@ int Render_Line_##NAME(TTF_Font *font, SDL_Surface *textbuf, int xstart, int yst
11581158
int remainder; \
11591159
Uint8 *saved_buffer = image->buffer; \
11601160
int saved_width = image->width; \
1161-
image->buffer += alignment; \
1161+
\
11621162
/* Position updated after glyph rendering */ \
11631163
x = xstart + FT_FLOOR(x) + image->left; \
11641164
y = ystart + FT_FLOOR(y) - image->top; \
11651165
\
1166+
if (image->buffer == NULL) { \
1167+
continue; \
1168+
} \
1169+
image->buffer += alignment; \
1170+
\
11661171
/* Make sure glyph is inside textbuf */ \
11671172
above_w = x + image->width - textbuf->w; \
11681173
above_h = y + image->rows - textbuf->h; \

0 commit comments

Comments
 (0)