diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 3dcb93016e4..68b32b125bc 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2003-11-18 Tom Tromey + + * jni.cc (_Jv_JNI_GetStringUTFChars): Fail gracefully if string + is null. + 2003-11-17 Graydon Hoare * javax/swing/plaf/basic/BasicDefaults.java: Rewrite to spec. diff --git a/libjava/jni.cc b/libjava/jni.cc index d311f60ff1c..007aabc4008 100644 --- a/libjava/jni.cc +++ b/libjava/jni.cc @@ -1298,10 +1298,12 @@ static const char * (JNICALL _Jv_JNI_GetStringUTFChars) (JNIEnv *env, jstring string, jboolean *isCopy) { - string = unwrap (string); - jsize len = JvGetStringUTFLength (string); try { + string = unwrap (string); + if (string == NULL) + return NULL; + jsize len = JvGetStringUTFLength (string); char *r = (char *) _Jv_Malloc (len + 1); JvGetStringUTFRegion (string, 0, string->length(), r); r[len] = '\0';