<AWT Dev> Small fix for crasher in AWT

Andrew Haley aph at redhat.com
Mon Dec 3 04:44:24 PST 2012


On 12/03/2012 10:43 AM, Artem Ananiev wrote:
> Hi, Andrew,
> 
> JNU_GetEnv will crash, if "jvm" parameter is NULL. I don't know if this 
> is a possible case, but I see (jvm != NULL) check, which makes be 
> believe it's possible.

Yes, absolutely it is.

> The rest of the fix looks fine.

I don't understand the point you're making.  The resulting code after
patching is

JavaVM* jvm = NULL;
static int ToolkitErrorHandler(Display * dpy, XErrorEvent * event) {
    JNIEnv * env;
    if (jvm != NULL) {
	env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
	if (env) {
	    return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit", "globalErrorHandler", "(JJ)I",
					      ptr_to_jlong(dpy), ptr_to_jlong(event)).i;
	}
    }
    return 0;
}

Andrew.




More information about the awt-dev mailing list