Hello, I've been in the list for a long time as a reader and after
years I finally managed to get a development computer and restarted
playing with current wine git.

There are about 15 bugs on bugzilla but none of them are related to
this. I'm trying the list first before opening a bug. It's quite
simple to reproduce, although I'm not sure if I can attach the hlp
file here since it's from windows. The crash happens because the help
file needs another help file. There is a button on the screen called
Glossary that needs a file called glossary.hlp. If this file does not
exist wine asks me to point it, if I answer No or yes and then cancel
file selection wine crashes on an assert.

The following lines are displayed on the console:
fixme:winhelp:WINHELP_GetWindowInfo Couldn't find window info for glossary
winhelp.c:270: WINHELP_GetWindowInfo: Assertion `0' failed.
wine: Assertion failed at address 0xb78f0424 (thread 003b), starting debugger...

The following lines are from file winhelp.c, around line 270.
...
    if (strcmp(name, "main") != 0)
    {
        WINE_FIXME("Couldn't find window info for %s\n", name);
        assert(0);
        return NULL;
    }
...

The function WINHELP_OpenHelpWindow does not resist
WINHELP_GetWindowInfo returning NULL. That was why the assert(0) was
added inside it to abort the program execution (as far as I see).
There are 3 calls like this (one on winhelp.c and the others on
macro.c):

...
    WINHELP_OpenHelpWindow(HLPFILE_PageByHash, hlpfile, lHash,
                           WINHELP_GetWindowInfo(hlpfile, wndname), show);
...

My approach to fix this is quite simple: instead of splitting the
above lines on different places and add a check for each of them the
easier way is to simply make OpenHelpWindow resist null pointers and
do not open anything because the user was already warned and asked for
the nonexistent file. The proposed solution (if I may call adding one
"if" a solution) is attached. If anyone has the problematic hlp file
that was the cause to add the assert(0) please send me. Looks like the
assert is there since wine 1.0 according to
http://source.winehq.org/source/programs/winhlp32/winhelp.c?v=wine-1.0

Best wishes,
Bruno

--
universe* god::bigbang (void); //and then it all began...
From 824d59111b704e3db4cb7ff89bc6bf9781ea53be Mon Sep 17 00:00:00 2001
From: Bruno Jesus <00cp...@gmail.com>
Date: Sat, 23 Jul 2011 00:17:47 -0300
Subject: winhelp.c: Resist nonexistent files instead of crashing with assert(0);

---
 programs/winhlp32/winhelp.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/programs/winhlp32/winhelp.c b/programs/winhlp32/winhelp.c
index a43a784..1247f13 100644
--- a/programs/winhlp32/winhelp.c
+++ b/programs/winhlp32/winhelp.c
@@ -22,7 +22,6 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
-#include <assert.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
@@ -264,12 +263,8 @@ HLPFILE_WINDOWINFO*     WINHELP_GetWindowInfo(HLPFILE* hlpfile, LPCSTR name)
             if (!lstrcmpi(hlpfile->windows[i].name, name))
                 return &hlpfile->windows[i];
 
-    if (strcmp(name, "main") != 0)
-    {
-        WINE_FIXME("Couldn't find window info for %s\n", name);
-        assert(0);
-        return NULL;
-    }
+    if (strcmp(name, "main") != 0) return NULL;
+
     if (!mwi.name[0])
     {
         strcpy(mwi.type, "primary");
@@ -882,7 +877,7 @@ BOOL WINHELP_OpenHelpWindow(HLPFILE_PAGE* (*lookup)(HLPFILE*, LONG, ULONG*),
                             int nCmdShow)
 {
     WINHELP_WNDPAGE     wpage;
-
+    if(!wi) return FALSE;
     wpage.page = lookup(hlpfile, val, &wpage.relative);
     if (wpage.page) wpage.page->file->wRefCount++;
     wpage.wininfo = wi;
-- 
1.7.2.5



Reply via email to