Skip to content

Commit 9205747

Browse files
authored
Merge branch 'main' into fix/performance
2 parents 74f75d0 + 27eec84 commit 9205747

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## [8.8.5](https://github.com/NativeScript/android/compare/v8.8.4...v8.8.5) (2024-09-30)
2+
3+
4+
### Bug Fixes
5+
6+
* prevent metadata offset overflow into array space and convert shorts to uints before addition ([9cfc349](https://github.com/NativeScript/android/commit/9cfc3493017243948b043a51f68b7c7bcab1e6b9))
7+
8+
9+
110
## [8.8.4](https://github.com/NativeScript/android/compare/v8.8.3...v8.8.4) (2024-09-06)
211

312

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@nativescript/android",
33
"description": "NativeScript for Android using v8",
4-
"version": "8.8.4",
4+
"version": "8.8.5",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/NativeScript/android.git"

test-app/build-tools/android-metadata-generator/src/src/com/telerik/metadata/Writer.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ public void writeTree(TreeNode root) throws Exception {
305305
outStringsStream.close();
306306
writeInt(0, outValueStream);
307307

308-
final int array_offset = 1000 * 1000 * 1000;
308+
final int array_offset = Integer.MAX_VALUE; // 2147483647, which is half of uint32
309309

310310
d.push(root);
311311
while (!d.isEmpty()) {
@@ -328,6 +328,10 @@ public void writeTree(TreeNode root) throws Exception {
328328
throw new Exception("should not happen");
329329
}
330330

331+
if ((n.nodeType & TreeNode.Array) != TreeNode.Array && Integer.toUnsignedLong(n.offsetValue) >= Integer.toUnsignedLong(array_offset)) {
332+
throw new Exception("Non-array metadata has overflown array space. Please report this issue.");
333+
}
334+
331335
d.addAll(n.children);
332336
}
333337

@@ -339,7 +343,7 @@ public void writeTree(TreeNode root) throws Exception {
339343
TreeNode n = d.pollFirst();
340344

341345
if (n.arrayElement != null) {
342-
n.offsetValue = array_offset + n.arrayElement.id;
346+
n.offsetValue = array_offset + Short.toUnsignedInt(n.arrayElement.id);
343347
}
344348

345349
if (!n.children.isEmpty()) {
@@ -387,6 +391,8 @@ public void writeTree(TreeNode root) throws Exception {
387391
obj.addProperty("id", Short.toUnsignedInt(n.id));
388392
obj.addProperty("nextSiblingId", Short.toUnsignedInt(n.nextSiblingId));
389393
obj.addProperty("firstChildId", Short.toUnsignedInt(n.firstChildId));
394+
obj.addProperty("offsetName", Integer.toUnsignedLong(n.offsetName));
395+
obj.addProperty("offsetValue", Integer.toUnsignedLong(n.offsetValue));
390396
obj.addProperty("name", n.getName());
391397
obj.addProperty("nodeType", n.nodeType);
392398
rootArray.add(obj);

test-app/runtime/src/main/cpp/MetadataReader.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ namespace tns {
219219
}
220220

221221
private:
222-
static const uint32_t ARRAY_OFFSET = 1000000000;
222+
223+
static const uint32_t ARRAY_OFFSET = INT32_MAX; // 2147483647
223224

224225
MetadataTreeNode *BuildTree();
225226

0 commit comments

Comments
 (0)