mirror of
https://github.com/corda/corda.git
synced 2025-01-05 20:54:13 +00:00
handle zero-length arrays in truncate functions
This commit is contained in:
parent
333b6c59d4
commit
8cb6446bec
@ -6216,8 +6216,10 @@ truncateIntArray(Thread* t, object array, unsigned length)
|
|||||||
PROTECT(t, array);
|
PROTECT(t, array);
|
||||||
|
|
||||||
object newArray = makeIntArray(t, length);
|
object newArray = makeIntArray(t, length);
|
||||||
memcpy(&intArrayBody(t, newArray, 0), &intArrayBody(t, array, 0),
|
if (length) {
|
||||||
length * 4);
|
memcpy(&intArrayBody(t, newArray, 0), &intArrayBody(t, array, 0),
|
||||||
|
length * 4);
|
||||||
|
}
|
||||||
|
|
||||||
return newArray;
|
return newArray;
|
||||||
}
|
}
|
||||||
@ -6230,8 +6232,10 @@ truncateArray(Thread* t, object array, unsigned length)
|
|||||||
PROTECT(t, array);
|
PROTECT(t, array);
|
||||||
|
|
||||||
object newArray = makeArray(t, length);
|
object newArray = makeArray(t, length);
|
||||||
memcpy(&arrayBody(t, newArray, 0), &arrayBody(t, array, 0),
|
if (length) {
|
||||||
length * BytesPerWord);
|
memcpy(&arrayBody(t, newArray, 0), &arrayBody(t, array, 0),
|
||||||
|
length * BytesPerWord);
|
||||||
|
}
|
||||||
|
|
||||||
return newArray;
|
return newArray;
|
||||||
}
|
}
|
||||||
@ -6244,9 +6248,11 @@ truncateLineNumberTable(Thread* t, object table, unsigned length)
|
|||||||
PROTECT(t, table);
|
PROTECT(t, table);
|
||||||
|
|
||||||
object newTable = makeLineNumberTable(t, length);
|
object newTable = makeLineNumberTable(t, length);
|
||||||
memcpy(&lineNumberTableBody(t, newTable, 0),
|
if (length) {
|
||||||
&lineNumberTableBody(t, table, 0),
|
memcpy(&lineNumberTableBody(t, newTable, 0),
|
||||||
length * sizeof(uint64_t));
|
&lineNumberTableBody(t, table, 0),
|
||||||
|
length * sizeof(uint64_t));
|
||||||
|
}
|
||||||
|
|
||||||
return newTable;
|
return newTable;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user