From 7a59a77ef33c5c3f96f1aeb8f6f1c9e323311b46 Mon Sep 17 00:00:00 2001 From: tromey Date: Tue, 18 Nov 2003 17:56:33 +0000 Subject: * jni.cc (_Jv_JNI_GetStringUTFChars): Fail gracefully if string is null. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@73707 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/jni.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libjava/jni.cc') 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'; -- cgit v1.2.1