diff -r b3c9090d1120 SDL_ttf.c --- a/SDL_ttf.c Sun Sep 10 00:41:53 2017 -0700 +++ b/SDL_ttf.c Sun Sep 10 14:04:15 2017 +0200 @@ -1480,6 +1480,11 @@ dst = (Uint8*) textbuf->pixels + (row+glyph->yoffset) * textbuf->pitch + xstart + glyph->minx; + + if (dst < (Uint8*) textbuf->pixels) { + dst = textbuf->pixels; + } + src = current->buffer + row * current->pitch; for (col=width; col>0 && dst < dst_check; --col) { @@ -1676,6 +1681,11 @@ dst = (Uint8*) textbuf->pixels + (row+glyph->yoffset) * textbuf->pitch + xstart + glyph->minx; + + if (dst < (Uint8*) textbuf->pixels) { + dst = textbuf->pixels; + } + src = current->buffer + row * current->pitch; for (col=width; col>0 && dst < dst_check; --col) { *dst++ |= *src++; @@ -1864,6 +1874,10 @@ (row+glyph->yoffset) * textbuf->pitch/4 + xstart + glyph->minx; + if (dst < (Uint8*) textbuf->pixels) { + dst = textbuf->pixels; + } + /* Added code to adjust src pointer for pixmaps to * account for pitch. * */ @@ -2168,6 +2182,10 @@ (row+glyph->yoffset) * textbuf->pitch/4 + xstart + glyph->minx; + if (dst < (Uint8*) textbuf->pixels) { + dst = textbuf->pixels; + } + /* Added code to adjust src pointer for pixmaps to * account for pitch. * */