From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22020 invoked by alias); 18 Nov 2003 17:54:55 -0000 Mailing-List: contact java-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-patches-owner@gcc.gnu.org Received: (qmail 22013 invoked from network); 18 Nov 2003 17:54:54 -0000 Received: from unknown (HELO gash2.peakpeak.com) (207.174.178.17) by sources.redhat.com with SMTP; 18 Nov 2003 17:54:54 -0000 Received: from fleche.redhat.com (lt658_076.peakpeak.com [199.165.157.76] (may be forged)) by gash2.peakpeak.com (8.9.3/8.9.3.1) with ESMTP id KAA12403 for ; Tue, 18 Nov 2003 10:54:53 -0700 Received: by fleche.redhat.com (Postfix, from userid 1000) id 9807F4F8288; Tue, 18 Nov 2003 10:45:26 -0700 (MST) To: GCC libjava patches Subject: Patch: FYI: JNI fixlet From: Tom Tromey Reply-To: tromey@redhat.com X-Attribution: Tom X-Zippy: Mary Tyler Moore's SEVENTH HUSBAND is wearing my DACRON TANK TOP in a cheap hotel in HONOLULU! Date: Tue, 18 Nov 2003 17:54:00 -0000 Message-ID: <87ekw5d0zv.fsf@fleche.redhat.com> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-q4/txt/msg00397.txt.bz2 I'm checking this in. My reading of the JNI spec is that GetStringUTFChars should handle the case where the string argument is NULL. In any case, it doesn't hurt to code this defensively. I'm fixing this as appended. Tom Index: ChangeLog from Tom Tromey * jni.cc (_Jv_JNI_GetStringUTFChars): Fail gracefully if string is null. Index: jni.cc =================================================================== RCS file: /cvs/gcc/gcc/libjava/jni.cc,v retrieving revision 1.79 diff -u -r1.79 jni.cc --- jni.cc 14 Nov 2003 01:48:28 -0000 1.79 +++ jni.cc 18 Nov 2003 17:51:37 -0000 @@ -1298,10 +1298,12 @@ (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';