Exit loop when font definition contains more characters then the image has data to...
authorIngo Ruhnke <grumbel@gmail.com>
Sun, 3 Aug 2014 04:42:05 +0000 (06:42 +0200)
committerIngo Ruhnke <grumbel@gmail.com>
Sun, 3 Aug 2014 04:42:05 +0000 (06:42 +0200)
src/video/font.cpp

index d9ccd08..00b7ec1 100644 (file)
@@ -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);