From 1f158324963da68ec3ed46a31bd91b360e1ee3ec Mon Sep 17 00:00:00 2001 From: Leon Jacobs Date: Tue, 8 Aug 2017 23:46:59 +0200 Subject: [PATCH] Ensure that an Array was received in toJniObjectArray() This allows for a failure to occur earlier instead of later in the call stack when the length property may be needed. --- lib/class-factory.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/class-factory.js b/lib/class-factory.js index d5a2dd22..2b6f2534 100644 --- a/lib/class-factory.js +++ b/lib/class-factory.js @@ -2241,6 +2241,11 @@ function toJniObjectArray (arr, env, classHandle, setObjectArrayFunc) { if (arr === null) { return NULL; } + + if (!(arr instanceof Array)) { + throw new Error("Expected an array."); + } + const length = arr.length; const result = env.newObjectArray(length, classHandle, NULL);