Fix a blit overflow if rect->x or rect->y < 0
authorMiriam Ruiz <miriam@debian.org>
Mon, 1 Dec 2008 08:09:49 +0000 (1 09:09 +0100)
committerMiriam Ruiz <miriam@debian.org>
Mon, 1 Dec 2008 08:09:49 +0000 (1 09:09 +0100)
See http://bugs.debian.org/439855
Copyright (C) 2007 Jens Seidel <jensseidel@users.sf.net>
Patch obtained from Debian Package release 0.1.2-4

src/SDL_Pango.c

index fe67da1..590924a 100644 (file)
@@ -725,16 +725,23 @@ SDLPango_CopyFTBitmapToSurface(
     int x = rect->x;\r
     int y = rect->y;\r
 \r
+    if(x < 0) {\r
+       width += x; x = 0;\r
+    }\r
     if(x + width > surface->w) {\r
        width = surface->w - x;\r
-       if(width <= 0)\r
-           return;\r
+    }\r
+    if(width <= 0)\r
+       return;\r
+\r
+    if(y < 0) {\r
+       height += y; y = 0;\r
     }\r
     if(y + height > surface->h) {\r
        height = surface->h - y;\r
-       if(height <= 0)\r
-           return;\r
     }\r
+    if(height <= 0)\r
+       return;\r
 \r
     if(SDL_LockSurface(surface)) {\r
        SDL_SetError("surface lock failed");\r