You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/07/01 11:12:36 UTC

svn commit: r790082 - /commons/sandbox/runtime/trunk/src/main/native/shared/string.c

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);
             }
         }