[AD] screen double-free patch (allegro 4.03)

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


The following patch to src/graphics.c moves the 'destroy vram bitmap' loop
so it happens after 'destroy_bitmap(screen);'.  This prevents 'screen'
from being freed twice (and thereby corrupting the heap and crashing in libc)
when allegro is shut down.


This should work, I don't make diff patches often:


diff -urN old/graphics.c new/graphics.c
--- old/graphics.c	2003-04-22 21:04:22.000000000 +0000
+++ new/graphics.c	2003-04-22 21:03:24.000000000 +0000
@@ -557,9 +557,6 @@
       if (_al_linker_mouse)
          _al_linker_mouse->show_mouse(NULL);
 
-      while (vram_bitmap_list)
-	 destroy_bitmap(vram_bitmap_list->bmp);
-
       bmp_read_line(screen, 0);
       bmp_write_line(screen, 0);
       bmp_unwrite_line(screen);
@@ -572,6 +569,9 @@
 
       destroy_bitmap(screen);
 
+      while (vram_bitmap_list)
+	 destroy_bitmap(vram_bitmap_list->bmp);
+
       gfx_driver = NULL;
       screen = NULL;
       gfx_capabilities = 0;




-- 
JP Morris - aka DOUG the Eagle (Dragon) -=UDIC=-  jpm@xxxxxxxxxx
Fun things to do with the Ultima games            http://www.it-he.org
Reign of the Just - An Ultima clone		  http://rotj.it-he.org
d+++ e+ N+ T++ Om U1234!56!7'!S'!8!9!KA u++ uC+++ uF+++ uG---- uLB----
uA--- nC+ nR---- nH+++ nP++ nI nPT nS nT wM- wC- y a(YEAR - 1976)




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