Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!nss1!mrm From: mrm@nss1.com (Michael R. Miller) Newsgroups: comp.windows.x Subject: Re: tvtwm patch 5 dumps core Summary: patch may not work as written Message-ID: <1991May15.094059.8696@nss1.com> Date: 15 May 91 09:40:59 GMT References: <1991May11.004433.14527@agate.berkeley.edu> Sender: uunet!nss1!mrm (Michael R. Miller) Organization: XZaphod of Rockville, MD Lines: 54 Send-Reply-To: uunet!xzaphod!michael In article <1991May11.004433.14527@agate.berkeley.edu> stolcke@ICSI.Berkeley.EDU (Andreas Stolcke) writes: >In article , jsparkes@bwdls49.bnr.ca (Jeff Sparkes) writes: >|> >|> It's dereferencing a null menu pointer. If you have menus on more >|> than one button: hold one down, and then press a button that brings up >|> another menu. Boom! > >That's gross! How about the following fix. > >-- >Andreas Stolcke stolcke@icsi.berkeley.edu >International Computer Science Institute stolcke@ucbicsi.bitnet >1957 Center St., Suite 600, Berkeley, CA 94704 (415) 642-4274 ext. 126 > >*** menus.c.dist Tue Apr 23 07:17:14 1991 >--- menus.c Fri May 10 17:32:06 1991 >*************** >*** 569,576 **** > > } > >! /* if we haven't recieved the enter notify yet, wait */ >! if (ActiveMenu && !ActiveMenu->entered) > continue; > > done = FALSE; >--- 569,576 ---- > > } > >! /* if we haven't received the enter notify yet, wait */ >! if (!ActiveMenu || !ActiveMenu->entered) > continue; > > done = FALSE; This is not a correct solution. C compilers are NOT constrained to resolve the '||' test in any particular order resulting in the test "!ActiveMenu->entered" possibly being accomplished prior to the checking of the validity (non-NULLness) of ActiveMenu. This can still core dump if compiled under some C compilers. Presuming the intent of the test is correct, _A_ correct way to implement this test is: if (!(ActiveMenu && ActiveMenu->entered)) continue; There isn't enough context here to determine if the intent of the test is correct or not. A guess would be that the intent is valid but that's only a guess. Michael R. Miller XZaphod: uunet!xzaphod!michael