Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 43034 invoked from network); 1 Jul 2009 09:12:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 Jul 2009 09:12:53 -0000 Received: (qmail 10491 invoked by uid 500); 1 Jul 2009 09:13:03 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 10403 invoked by uid 500); 1 Jul 2009 09:13:02 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 10380 invoked by uid 99); 1 Jul 2009 09:13:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Jul 2009 09:13:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Jul 2009 09:12:58 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9EDAB23888E3; Wed, 1 Jul 2009 09:12:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r790082 - /commons/sandbox/runtime/trunk/src/main/native/shared/string.c Date: Wed, 01 Jul 2009 09:12:36 -0000 To: commits@commons.apache.org From: mturk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090701091236.9EDAB23888E3@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mturk Date: Wed Jul 1 09:12:36 2009 New Revision: 790082 URL: http://svn.apache.org/viewvc?rev=790082&view=rev Log: Throw exception if trying to create UTF-8 from invalis char sequence Modified: commons/sandbox/runtime/trunk/src/main/native/shared/string.c Modified: commons/sandbox/runtime/trunk/src/main/native/shared/string.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/string.c?rev=790082&r1=790081&r2=790082&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/shared/string.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/shared/string.c Wed Jul 1 09:12:36 2009 @@ -481,19 +481,24 @@ { jstring rs = NULL; if (s) { + int ex; jsize sl = (jsize)strlen(s); if (sl < ACR_MBUFF_SIZ) { jchar cc[ACR_MBUFF_SIZ]; jsize wl = ACR_MBUFF_LEN; - if (conv_utf8_to_ucs2(s, sl, cc, &wl) == ACR_SUCCESS) + if ((ex = conv_utf8_to_ucs2(s, sl, cc, &wl)) == ACR_SUCCESS) rs = (*_E)->NewString(_E, cc, sl); + else + ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINVAL, ex); } else { jchar *cc; if ((cc = ACR_Malloc(_E, THROW_FMARK, (sl + 1) * sizeof(jchar)))) { jsize wl = sl; - if (conv_utf8_to_ucs2(s, sl, cc, &wl) == ACR_SUCCESS) + if ((ex = conv_utf8_to_ucs2(s, sl, cc, &wl)) == ACR_SUCCESS) rs = (*_E)->NewString(_E, cc, sl); + else + ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINVAL, ex); free(cc); } }