[AD] win_set_window problem?

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


It seems win_set_window, if called with NULL or being reinitialized, may cause certain parts of Allegro to be initialized when they're not supposed to. The problem is here:

static void exit_window_modules(struct WINDOW_MODULES *wm)
{
   if (wm)
      memset(wm, 0, sizeof(wm));
   ...
}

This will only zero-out the first four bytes of the structure and may leave certain parts non-zero (and thus later reinitialize portions of Allegro that shouldn't be). The attached patch 0's it all out.

- Kitty Cat
Index: src/win/wwnd.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/win/wwnd.c,v
retrieving revision 1.80
diff -u -r1.80 wwnd.c
--- src/win/wwnd.c	15 Sep 2004 06:20:13 -0000	1.80
+++ src/win/wwnd.c	19 Sep 2004 04:14:13 -0000
@@ -119,7 +119,7 @@
 static void exit_window_modules(struct WINDOW_MODULES *wm)
 {
    if (wm)
-      memset(wm, 0, sizeof(wm));
+      memset(wm, 0, sizeof(struct WINDOW_MODULES));
 
    if (_keyboard_installed) {
      if (wm)


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