r5383 vince - /branches/vince/netsurf-fb/framebuffer/fb_cursor.c

netsurf at semichrome.net netsurf at semichrome.net
Sun Sep 21 00:00:15 BST 2008


Author: vince
Date: Sat Sep 20 18:00:15 2008
New Revision: 5383

URL: http://source.netsurf-browser.org?rev=5383&view=rev
Log:
fix segfault when cursor is off teh bottom of teh screen

Modified:
    branches/vince/netsurf-fb/framebuffer/fb_cursor.c

Modified: branches/vince/netsurf-fb/framebuffer/fb_cursor.c
URL: http://source.netsurf-browser.org/branches/vince/netsurf-fb/framebuffer/fb_cursor.c?rev=5383&r1=5382&r2=5383&view=diff
==============================================================================
--- branches/vince/netsurf-fb/framebuffer/fb_cursor.c (original)
+++ branches/vince/netsurf-fb/framebuffer/fb_cursor.c Sat Sep 20 18:00:15 2008
@@ -80,9 +80,16 @@
         int savelen;
         uint8_t *pvid;
         int yloop;
+        int height = fb->cursor->height;
+
+        if ((fb->height - fb->cursor->y) < height)
+                height = (fb->height - fb->cursor->y);
+
+        if (height == 0)
+                return;
 
         savelen = ((fb->cursor->width * fb->bpp) / 8);
-        savebuf = malloc(savelen * fb->cursor->height);
+        savebuf = malloc(savelen * height);
         if (savebuf == NULL)
                 return;
 
@@ -95,7 +102,7 @@
                (fb->cursor->y  * fb->linelen) + 
                ((fb->cursor->x * fb->bpp) / 8);
 
-        for (yloop=0; yloop < fb->cursor->height; yloop++) {
+        for (yloop=0; yloop < height; yloop++) {
                 memcpy(savebuf, pvid, savelen);
                 savebuf += savelen;
                 pvid += fb->linelen;
@@ -108,6 +115,13 @@
         int savelen;
         uint8_t *pvid;
         int yloop;
+        int height = fb->cursor->height;
+
+        if ((fb->height - fb->cursor->y) < height)
+                height = (fb->height - fb->cursor->y);
+
+        if (height == 0)
+                return;
 
         if (fb->cursor->plotted == false)
                 return;
@@ -123,7 +137,7 @@
                (fb->cursor->y  * fb->linelen) + 
                ((fb->cursor->x * fb->bpp) / 8);
 
-        for (yloop=0; yloop < fb->cursor->height; yloop++) {
+        for (yloop=0; yloop < height; yloop++) {
                 memcpy(pvid, savebuf, savelen);
                 savebuf += savelen;
                 pvid += fb->linelen;




More information about the netsurf-commits mailing list