You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2007/06/13 14:44:47 UTC

svn commit: r546844 - /harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp

Author: gshimansky
Date: Wed Jun 13 05:44:46 2007
New Revision: 546844

URL: http://svn.apache.org/viewvc?view=rev&rev=546844
Log:
Applied patch from HARMONY-4030
[drlvm][classloader] Fixed bug prone code in Class_File_Loader file


Modified:
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp?view=diff&rev=546844&r1=546843&r2=546844
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class_File_Loader.cpp Wed Jun 13 05:44:46 2007
@@ -650,9 +650,9 @@
 }
 
 // JVM spec:
-// Unqualified names must not contain the characters ’.’, ’;’, ’[’ or ’/’. Method names are
-// further constrained so that, with the exception of the special method names (§3.9)
-// <init> and <clinit>, they must not contain the characters ’<’ or ’>’.
+// Unqualified names must not contain the characters ".", ";", "[" or "/". Method names are
+// further constrained so that, with the exception of the special method names (§3.9)
+// <init> and <clinit>, they must not contain the characters "<" or ">".
 static inline bool
 check_member_name(const char *name, unsigned len, bool old_version, bool is_method)
 {
@@ -660,17 +660,30 @@
         return is_identifier(name, len);
     }else {
         for (unsigned i = 0; i < len; i++) {
-            switch(name[i]){
-            case '.':
-            case ';':
-            case '[':
-            case '/':
-                return false;
-            case '<':
-            case '>':
-                if(is_method)
+            //check if symbol has byte size
+            if(!(name[i] & 0x80)) {
+                switch(name[i]) {
+                case '.':
+                case ';':
+                case '[':
+                case '/':
                     return false;
-                break;    
+                case '<':
+                case '>':
+                    if(is_method)
+                        return false;
+                }
+	    } else { //skip other symbols, they are not in exception list
+                assert(name[i] & 0x40);
+                if(name[i] & 0x20) {
+                    if(len - i - 3 < 0) //check array bound
+                        return false;
+                    i += 2;
+                    } else {
+                    if(len - i - 2 < 0)
+                        return false;
+                    i++;
+                }    
             }
         }
     }
@@ -1801,6 +1814,7 @@
                 STD_FREE(generic_vars);
             }
         }
+
         if (failed) {
             return false;
         }
@@ -1829,7 +1843,7 @@
     {
         result = check_field_descriptor(descriptor, &next, false, old_version);
         if( !result || *next == '\0' ) {
-            return result;
+            return false;
         }
         descriptor = next;
     }