hotspot/src/share/vm/oops/objArrayOop.hpp
changeset 4465 7b73e0380188
parent 4461 c17c526d36ef
child 5547 f4b087cbb361
--- a/hotspot/src/share/vm/oops/objArrayOop.hpp	Mon Dec 07 14:22:34 2009 -0500
+++ b/hotspot/src/share/vm/oops/objArrayOop.hpp	Tue Dec 08 15:12:17 2009 -0800
@@ -58,7 +58,7 @@
       old_res = align_size_up(length, OopsPerHeapWord)/OopsPerHeapWord;
     }
 #endif  // ASSERT
-    int res = (length + OopsPerHeapWord - 1)/OopsPerHeapWord;
+    int res = ((uint)length + OopsPerHeapWord - 1)/OopsPerHeapWord;
     assert(res == old_res, "Inconsistency between old and new.");
     return res;
   }
@@ -96,7 +96,11 @@
 
   static int object_size(int length) {
     // This returns the object size in HeapWords.
-    return align_object_size(header_size() + array_size(length));
+    uint asz = array_size(length);
+    uint osz = align_object_size(header_size() + asz);
+    assert(osz >= asz,   "no overflow");
+    assert((int)osz > 0, "no overflow");
+    return (int)osz;
   }
 
   // special iterators for index ranges, returns size of object