From: Ingo Ruhnke Date: Sun, 3 Aug 2014 04:42:05 +0000 (+0200) Subject: Exit loop when font definition contains more characters then the image has data to... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=45c2bacea26edf50bace0fdae72cd854fe6550c4;p=supertux.git Exit loop when font definition contains more characters then the image has data to avoid crash --- 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);