mirror of
https://github.com/corda/corda.git
synced 2025-01-04 04:04:27 +00:00
fix incorrect array sizing in populateMultiArray
We were assuming the array element size was always the native word size, which is not correct in general for primitive arrays, and this led to wasted space at best and memory corruption at worst.
This commit is contained in:
parent
cfd9dc6656
commit
156644b8e5
@ -4889,7 +4889,10 @@ populateMultiArray(Thread* t, object array, int32_t* counts,
|
||||
PROTECT(t, class_);
|
||||
|
||||
for (int32_t i = 0; i < counts[index]; ++i) {
|
||||
object a = makeArray(t, counts[index + 1]);
|
||||
object a = makeArray
|
||||
(t, ceiling
|
||||
(counts[index + 1] * classArrayElementSize(t, class_), BytesPerWord));
|
||||
arrayLength(t, a) = counts[index + 1];
|
||||
setObjectClass(t, a, class_);
|
||||
set(t, array, ArrayBody + (i * BytesPerWord), a);
|
||||
|
||||
|
@ -260,5 +260,17 @@ public class Floats {
|
||||
int result = Float.floatToIntBits(number);
|
||||
expect(result == orig);
|
||||
}
|
||||
|
||||
for (int x = 0; x < 1000; ++x) {
|
||||
int m = 100;
|
||||
int n = 200;
|
||||
double array[][] = new double[m][n];
|
||||
|
||||
for (int i = 0; i < m; ++i) {
|
||||
for (int j = 0; j < n; ++j) {
|
||||
array[i][j] = 1234567890.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user