[AD] bugfix in floodfill()

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Hi,
the following program exploits a bug in floodfill. The problem is a limit of 32767 elements in a linked list, but with this evil example the linked list needs a number of elements proportional to the number of pixels on screen. Patch attached.

   #include <allegro.h>
   int main(void) {
     int i;
     allegro_init();
     set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
     clear(screen);
     for (i=0; i<640; i+=4) {
       line(screen, i, 1, i, 479, 1);
       line(screen, i+2, 0, i+2, 478, 1);
     }
     floodfill(screen, 0, 0, 2);
     return 0;
  }
  END_OF_MAIN()

--
Sven
Index: src/flood.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/flood.c,v
retrieving revision 1.4
diff -u -r1.4 flood.c
--- src/flood.c	12 Sep 2002 16:23:56 -0000	1.4
+++ src/flood.c	11 Oct 2003 13:40:37 -0000
@@ -28,7 +28,7 @@
    short flags;                  /* status of the segment */
    short lpos, rpos;             /* left and right ends of segment */
    short y;                      /* y coordinate of the segment */
-   short next;                   /* linked list if several per line */
+   int next;                     /* linked list if several per line */
 } FLOODED_LINE;
 
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/