From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Ben Key" Newsgroups: gmane.emacs.devel,gmane.emacs.sources Subject: Fix for Emacs Crash Date: Wed, 6 Nov 2002 23:05:16 -0500 Sender: emacs-devel-admin@gnu.org Message-ID: <002101c28612$e1e15710$6501a8c0@GODDESS> Reply-To: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0022_01C285E8.F90B4F10" X-Trace: main.gmane.org 1036642503 13841 80.91.224.249 (7 Nov 2002 04:15:03 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 7 Nov 2002 04:15:03 +0000 (UTC) Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 189e4L-0003ar-00 for ; Thu, 07 Nov 2002 05:15:01 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 189eD9-00055M-00 for ; Thu, 07 Nov 2002 05:24:07 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 189e5d-0005Ys-00; Wed, 06 Nov 2002 23:16:21 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 189dv7-000536-00 for emacs-devel@gnu.org; Wed, 06 Nov 2002 23:05:29 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 189dv4-00052o-00 for emacs-devel@gnu.org; Wed, 06 Nov 2002 23:05:28 -0500 Original-Received: from smtp-server2-bak.tampabay.rr.com ([65.32.1.45] helo=smtp-server2.tampabay.rr.com) by monty-python.gnu.org with esmtp (Exim 4.10) id 189dv0-000513-00; Wed, 06 Nov 2002 23:05:22 -0500 Original-Received: from GODDESS (6535194hfc48.tampabay.rr.com [65.35.194.48]) by smtp-server2.tampabay.rr.com (8.12.2/8.12.2) with SMTP id gA745GS8016757; Wed, 6 Nov 2002 23:05:16 -0500 (EST) Original-To: "Emacs-Devel \(E-mail\)" , "Gnu-Emacs-Sources \(E-mail\)" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:9207 gmane.emacs.sources:203 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:9207 This is a multi-part message in MIME format. ------=_NextPart_000_0022_01C285E8.F90B4F10 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit The following patch fixes a bug I experienced when running a build of GNU Emacs I made on Windows XP SP1 on Windows 2000 SP2. The crash occurred when starting Emacs. --- _21.3/src/w32menu.c 2002-08-05 12:33:44.000000000 -0400 +++ 21.3/src/w32menu.c 2002-11-06 23:01:11.000000000 -0500 @@ -2215,9 +2215,11 @@ info.fState = wv->selected ? MFS_CHECKED : MFS_UNCHECKED; } - set_menu_item_info (menu, - item != NULL ? (UINT) item : (UINT) wv->call_data, - FALSE, &info); + set_menu_item_info ( + menu, + item != NULL ? (UINT) item : (UINT) wv->call_data, + item != NULL ? FALSE : TRUE, + &info); } } return return_value; The logic behind this patch is as follows: * The documentation of SetMenuItemInfo from the MSDN Library is as follows: SetMenuItemInfo The SetMenuItemInfo function changes information about a menu item. BOOL SetMenuItemInfo( HMENU hMenu, // handle to menu UINT uItem, // identifier or position BOOL fByPosition, // meaning of uItem LPMENUITEMINFO lpmii // menu item information ); Parameters hMenu [in] Handle to the menu that contains the menu item. uItem [in] Identifier or position of the menu item to change. The meaning of this parameter depends on the value of fByPosition. fByPosition [in] Value specifying the meaning of uItem. If this parameter is FALSE, uItem is a menu item identifier. Otherwise, it is a menu item position. lpmii [in] Pointer to a MENUITEMINFO structure that contains information about the menu item and specifies which menu item attributes to change. Return Values If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, use the GetLastError function. * I interpreted the line item != NULL ? (UINT) item : (UINT) wv->call_data, to mean if item is not NULL, use the specified menu identifier, otherwise use the position specified by the call_data member of the wv structure. * Based upon this interpretation, passing SetMenuItemInfo a value of FALSE for the fByPosition parameter unconditionally is obviously incorrect. Instead fByPosition should only be FALSE if item is non NULL. Please let me know if my logic behind this fix is flawed. I am not absolutely certain that the call_data member of the wv structure is supposed to the position index if the item in the menu because I have not yet determined how its value is getting set. I have tested this fix by successfully running a build of Emacs done on a Windows XP machine using MSVC 6.0 on Windows 2000. NOTE: I have no idea why this crash only occurred when running Emacs on a version of Windows other than the one on which it was built. All I know is that when I remote debugged Emacs to determine why I could not run the build I did on Windows XP on Windows 2000, Emacs crashed on this function call and item at that point was NULL. ------=_NextPart_000_0022_01C285E8.F90B4F10 Content-Type: application/octet-stream; name="21_3-w32menu.c.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="21_3-w32menu.c.diff" --- _21.3/src/w32menu.c 2002-08-05 12:33:44.000000000 -0400=0A= +++ 21.3/src/w32menu.c 2002-11-06 23:01:11.000000000 -0500=0A= @@ -2215,9 +2215,11 @@=0A= info.fState =3D wv->selected ? MFS_CHECKED : MFS_UNCHECKED;=0A= }=0A= =0A= - set_menu_item_info (menu,=0A= - item !=3D NULL ? (UINT) item : (UINT) wv->call_data,=0A= - FALSE, &info);=0A= + set_menu_item_info (=0A= + menu,=0A= + item !=3D NULL ? (UINT) item : (UINT) wv->call_data,=0A= + item !=3D NULL ? FALSE : TRUE,=0A= + &info);=0A= }=0A= }=0A= return return_value;=0A= ------=_NextPart_000_0022_01C285E8.F90B4F10--