Subject: xsrc/20619: Empty TwmWindows menu crashes
To: None <gnats-bugs@gnats.netbsd.org>
From: None <yh@metroweb.co.za>
List: netbsd-bugs
Date: 03/08/2003 16:36:07
>Number:         20619
>Category:       xsrc
>Synopsis:       Empty TwmWindows menu crashes
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    xsrc-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Mar 08 06:38:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Yorick Hardy
>Release:        NetBSD 1.6_STABLE
>Organization:
>Environment:
System: NetBSD Yorick 1.6_STABLE NetBSD 1.6_STABLE (YORICK) #277: Sat Mar 8 14:53:36 SAST 2003 yorick@Yorick:/usr/src/sys/arch/i386/compile/YORICK i386
Architecture: i386
Machine: i386
>Description:
twm will crash if the TwmWindows menu is used when no windows are currently
open. In other words twm crashes due to an empty window list.
>How-To-Repeat:
Display the TwmWindows menu when no windows are open.
>Fix:

*** xc/programs/twm/menus.c.orig	Sun Oct  6 22:19:14 2002
--- xc/programs/twm/menus.c	Mon Oct  7 17:26:05 2002
***************
*** 1039,1047 ****
--- 1039,1049 ----
              tmp_win != NULL;
              tmp_win = tmp_win->next)
            WindowNameCount++;
+         if (WindowNameCount != 0)
          WindowNames =
            (TwmWindow **)malloc(sizeof(TwmWindow *)*WindowNameCount);
          WindowNames[0] = Scr->TwmRoot.next;
+         if (WindowNameCount != 0)
          for(tmp_win = Scr->TwmRoot.next->next , WindowNameCount=1;
              tmp_win != NULL;
              tmp_win = tmp_win->next,WindowNameCount++)
>Release-Note:
>Audit-Trail:
>Unformatted: