jni.cc (_Jv_JNI_GetStringUTFChars): Fail gracefully if string is null.

* jni.cc (_Jv_JNI_GetStringUTFChars): Fail gracefully if string
	is null.

From-SVN: r73707
This commit is contained in:
Tom Tromey 2003-11-18 17:56:33 +00:00 committed by Tom Tromey
parent b9c5315018
commit 6c363de7ea
2 changed files with 9 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2003-11-18 Tom Tromey <tromey@redhat.com>
* jni.cc (_Jv_JNI_GetStringUTFChars): Fail gracefully if string
is null.
2003-11-17 Graydon Hoare <graydon@redhat.com>
* javax/swing/plaf/basic/BasicDefaults.java: Rewrite to spec.

View File

@ -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';