From 45c2bacea26edf50bace0fdae72cd854fe6550c4 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Sun, 3 Aug 2014 06:42:05 +0200 Subject: [PATCH] Exit loop when font definition contains more characters then the image has data to avoid crash --- src/video/font.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/video/font.cpp b/src/video/font.cpp index d9ccd08df..00b7ec1e1 100644 --- a/src/video/font.cpp +++ b/src/video/font.cpp @@ -206,6 +206,12 @@ Font::loadFontSurface( } else { + if (y + char_height > surface->h) + { + log_warning << "error: font definition contains more letter then the images: " << glyphimage << std::endl; + goto abort; + } + int left = x; while (left < x + char_width && vline_empty(surface, left, y, y + char_height, 64)) left += 1; @@ -234,7 +240,8 @@ Font::loadFontSurface( row++; } } - +abort: + if( surface != NULL ) { SDL_UnlockSurface(surface); SDL_FreeSurface(surface); -- 2.11.0