diff --git a/CHANGELOG.txt b/CHANGELOG.txt index bc43676b3..c44474819 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,6 +4,7 @@ D1X-Rebirth Changelog -------- main/newmenu.c: Fix memory errors, but still dynamically allocate menu and lb so it doesn't have to stay in newmenu_do4 and newmenu_listbox1 respectively main/automap.c, main/game.c, main/game.h, main/multi.c, main/multi.h, main/net_ipx.c, main/net_udp.c, main/newmenu.c: Fix crashing when doing menus in multiplayer, don't let player move when in automap +main/automap.c, main/kconfig.c, main/newmenu.c: Adding a bunch of memset's to menu/automap creations so we won't run into uninitialized variables 20100130 -------- diff --git a/main/automap.c b/main/automap.c index 3e1d2cdf1..c0ac4cbb1 100644 --- a/main/automap.c +++ b/main/automap.c @@ -561,8 +561,12 @@ void do_automap( int key_code ) automap *am; MALLOC(am, automap, 1); + if (am) + { + memset(am, 0, sizeof(automap)); automap_wind = window_create(&grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT, (int (*)(window *, d_event *, void *)) automap_handler, am); + } if (automap_wind == NULL) { diff --git a/main/kconfig.c b/main/kconfig.c index 9e0fc134d..d9818241e 100644 --- a/main/kconfig.c +++ b/main/kconfig.c @@ -963,9 +963,11 @@ void kconfig_sub(kc_item * items,int nitems, char *title) kc_menu *menu; MALLOC(menu, kc_menu, 1); + if (!menu) return; + memset(menu, 0, sizeof(kc_menu)); menu->time_stopped = 0; menu->items = items; menu->nitems = nitems; diff --git a/main/newmenu.c b/main/newmenu.c index 59eef7d23..353ea84a6 100644 --- a/main/newmenu.c +++ b/main/newmenu.c @@ -1277,9 +1277,11 @@ int newmenu_do4( char * title, char * subtitle, int nitems, newmenu_item * item, int done = 0; MALLOC(menu, newmenu, 1); + if (!menu) return -1; - + + memset(menu, 0, sizeof(newmenu)); menu->scroll_offset = 0; menu->last_scroll_check = -1; menu->all_text = 0; @@ -1972,9 +1974,11 @@ int newmenu_listbox1( char * title, int nitems, char * items[], int allow_abort_ int done = 0; MALLOC(lb, listbox, 1); + if (!lb) return -1; - + + memset(lb, 0, sizeof(listbox)); newmenu_close(); lb->title = title;