diff options
author | Carl Shapiro <cshapiro@google.com> | 2011-04-18 15:08:21 -0700 |
---|---|---|
committer | Carl Shapiro <cshapiro@google.com> | 2011-04-18 15:24:03 -0700 |
commit | 2ba33db462c43d054aac98293104cb4adb8dd562 (patch) | |
tree | 7455bb2faceef7fc8af08c492b81889f582b502d | |
parent | f0cf2df21a587816e42d9fb62dbd9d17a6f15978 (diff) | |
download | android_dalvik-2ba33db462c43d054aac98293104cb4adb8dd562.tar.gz android_dalvik-2ba33db462c43d054aac98293104cb4adb8dd562.tar.bz2 android_dalvik-2ba33db462c43d054aac98293104cb4adb8dd562.zip |
Fix a type error in the allocation of non-moving arrays.
Originally, non-moving arrays were allocated with dvmAllocObjectArray.
However, dvmAllocObjectArray does not respect the width of the user
supplied element class and substitutes a hard coded value of 4 bytes.
This change replaces dvmAllocObjectArray with dvmAllocArrayByClass.
dvmAllocArrayByClass consults the element class for its width when
computing the storage size for the array being allocated.
Bug: 4309030
Change-Id: I4f3802b38261f5ad7052d577049732f59a667ea6
-rw-r--r-- | vm/native/dalvik_system_VMRuntime.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/vm/native/dalvik_system_VMRuntime.cpp b/vm/native/dalvik_system_VMRuntime.cpp index 8d849915e..b704e3e36 100644 --- a/vm/native/dalvik_system_VMRuntime.cpp +++ b/vm/native/dalvik_system_VMRuntime.cpp @@ -97,7 +97,6 @@ static void Dalvik_dalvik_system_VMRuntime_newNonMovableArray(const u4* args, { ClassObject* elementClass = (ClassObject*) args[1]; int length = args[2]; - ArrayObject* newArray; if (elementClass == NULL) { dvmThrowNullPointerException(NULL); @@ -111,7 +110,10 @@ static void Dalvik_dalvik_system_VMRuntime_newNonMovableArray(const u4* args, // TODO: right now, we don't have a copying collector, so there's no need // to do anything special here, but we ought to pass the non-movability // through to the allocator. - newArray = dvmAllocObjectArray(elementClass, length, ALLOC_DEFAULT); + ClassObject* arrayClass = dvmFindArrayClassForElement(elementClass); + ArrayObject* newArray = dvmAllocArrayByClass(arrayClass, + length, + ALLOC_DEFAULT); if (newArray == NULL) { assert(dvmCheckException(dvmThreadSelf())); RETURN_VOID(); |