changeset 4732:1d0fba8a2a6d

8013574: PrintMalloc conflicts with the command line parsing Summary: Make sure that _num_jvm_args is not updated until the new entry to _jvm_args_array has been added Reviewed-by: johnc, tamao, tschatzl
author brutisso
date Thu, 02 May 2013 22:35:15 +0200
parents 9075044ed66b
children f14063dcd52a
files src/share/vm/runtime/arguments.cpp
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/runtime/arguments.cpp	Tue Apr 30 16:36:24 2013 +0200
+++ b/src/share/vm/runtime/arguments.cpp	Thu May 02 22:35:15 2013 +0200
@@ -747,16 +747,16 @@
     return;
   }
 
-  int index = *count;
+  int new_count = *count + 1;
 
   // expand the array and add arg to the last element
-  (*count)++;
   if (*bldarray == NULL) {
-    *bldarray = NEW_C_HEAP_ARRAY(char*, *count, mtInternal);
+    *bldarray = NEW_C_HEAP_ARRAY(char*, new_count, mtInternal);
   } else {
-    *bldarray = REALLOC_C_HEAP_ARRAY(char*, *bldarray, *count, mtInternal);
+    *bldarray = REALLOC_C_HEAP_ARRAY(char*, *bldarray, new_count, mtInternal);
   }
-  (*bldarray)[index] = strdup(arg);
+  (*bldarray)[*count] = strdup(arg);
+  *count = new_count;
 }
 
 void Arguments::build_jvm_args(const char* arg) {