harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r597634 - /harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/methodtable.cpp
Date Fri, 23 Nov 2007 10:33:15 GMT
Author: varlax
Date: Fri Nov 23 02:33:15 2007
New Revision: 597634

URL: http://svn.apache.org/viewvc?rev=597634&view=rev
Log:
Fixed HARMONY-5124 [drlvm][jitrino] Bugs in the implementation of Method_Table class

Modified:
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/methodtable.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/methodtable.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/methodtable.cpp?rev=597634&r1=597633&r2=597634&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/methodtable.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/methodtable.cpp Fri Nov 23 02:33:15
2007
@@ -189,14 +189,15 @@
 // Returns true on success, false on failure
 bool Method_Table::read_method_table()
 {
-    char buf[1000];
+    const size_t max_size = 1000;
+    char buf[max_size];
     FILE *file = fopen(_method_file, "r");
     if (file == NULL)
     {
         fprintf(stderr, "Couldn't open method table file %s\n", _method_file);
         return false;
     }
-    while (fgets(buf, 1000, file) != NULL)
+    while (fgets(buf, max_size, file) != NULL)
     {
         // strip out any newline at the end
         int buflen = (int) strlen(buf);
@@ -226,22 +227,25 @@
 
 void Method_Table::init(const char *default_envvar, const char *envvarname)
 {
-
-    char *rangestr;
-
-    char *envvar = (char*)default_envvar;
-
-    if (envvar == NULL || envvar[0] == '\0')
+    if (default_envvar == NULL || default_envvar[0] == '\0')
     {
         return;
     }
-    // strip away double-quote characters
-    if (envvar[0] == '"')
-        envvar ++;
-    if (envvar[strlen(envvar)-1] == '"')
-        envvar[strlen(envvar)-1] = '\0';
+
+    char *rangestr;
+    char *envvar = strdup(_mm, default_envvar);
     
+   // strip away double-quote characters
+    if (envvar[0] == '"') {
+        envvar ++;
+    }
     int evlen = (int) strlen(envvar);
+    if (evlen > 0 && envvar[evlen-1] == '"') {
+        envvar[--evlen] = '\0';
+    }
+    if (evlen == 0) {
+        return;
+    }
     int i;
     for (i=evlen-1; i>=0; i--)
     {



Mime
View raw message