Subject: pkg/13148: windowmaker crash
To: None <gnats-bugs@gnats.netbsd.org>
From: None <anthony.mallet@ficus.yi.org>
List: netbsd-bugs
Date: 06/09/2001 12:47:25
>Number:         13148
>Category:       pkg
>Synopsis:       windowmaker crash
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jun 09 03:46:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Anthony Mallet
>Release:        NetBSD-1.5.1_BETA2
>Organization:
>Environment:
System: NetBSD ficus 1.5.1_BETA2 NetBSD 1.5.1_BETA2 (FICUS) #9: Wed May 30 21:26:59 CEST 2001 toto@ficus:/home/src/netbsd-1.5/sys/arch/i386/compile/FICUS i386

>Description:
	Since 0.65.0, windowmaker started to crash for one particular
application, that does not seem to set WM_CLASS properties. Note that I
am using XFree-4.0.3 from XFree repository, which might affect the
behavior I noticed (I was using 4.0.2 with older version of windowmaker
without any --- visible --- problems).

For those who cares it was in the file src/application.c, in the function
wApplicationIndexOfGroup() : no tests are performed on wm_instance and
wm_class members and an strcmp() with a NULL pointer can make the window
manager segfault. 

I submitted the patch below to the windowmaker team, but it might not be
"The Good Solution" as I do not know about the intrinsics of that window
manager (for instance one could want to check for NULL pointers
everywhere but sometimes one find assert(wm_instance != NULL) in some
files, so I thought those pointers should never be NULL).

Anyway the patch fixes the problem and since I am a bit doubious about
the windowmaker team reactivity, I submit the patch here also.

>How-To-Repeat:
	Find an application that do not set WM_CLASS properties (in my
case this was a tcl "toplevel" widget, but I did not investigate further)
and try to launch it with wmaker 0.65.0.

>Fix:

--- src/properties.c~   Tue Oct 31 15:57:25 2000
+++ src/properties.c    Fri Jun  8 21:57:59 2001
@@ -81,8 +81,8 @@
 
     class_hint = XAllocClassHint();
     if (XGetClassHint(dpy,window,class_hint) == 0) {
-       *wm_class = NULL;
-       *wm_instance = NULL;
+       *wm_class = strdup("default");
+       *wm_instance = strdup("default");
        XFree(class_hint);
        return False;
     }
>Release-Note:
>Audit-Trail:
>Unformatted: