From a49b41b8945e534dc682e0f2533df7cea9b84293 Mon Sep 17 00:00:00 2001 From: Grant Date: Mon, 28 Sep 2020 16:45:25 +0100 Subject: [PATCH 1/3] extra validation of UINode object handles --- lib/node.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/node.js b/lib/node.js index 4f14c3b..ec03c14 100644 --- a/lib/node.js +++ b/lib/node.js @@ -44,12 +44,16 @@ function keepViewsAlive() { function UINode(view) { this.instance = view; keepViewsAlive(); - const activeKey = view.handle.toString(); - if (!(activeKey in activeInstances)) { - view.retain(); - activeInstances[activeKey] = new Set([this]); - } else { - activeInstances[activeKey].add(this); + + const handle = view.handle; + if (handle !== null && handle !== undefined) { + const activeKey = handle.toString(); + if (!(activeKey in activeInstances)) { + view.retain(); + activeInstances[activeKey] = new Set([this]); + } else { + activeInstances[activeKey].add(this); + } } if (UIWebViewClass === null) { From 851e8bfc61cf6702f5fc0a16445607c7ace7b9b2 Mon Sep 17 00:00:00 2001 From: Grant Date: Tue, 29 Sep 2020 13:18:41 +0100 Subject: [PATCH 2/3] fix root cause of bug --- lib/node.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node.js b/lib/node.js index ec03c14..9c6891a 100644 --- a/lib/node.js +++ b/lib/node.js @@ -233,7 +233,7 @@ function performOnMainThread(action) { } function readStringProperty(value) { - return (value !== null) ? value.toString() : ''; + return (value !== null && value !== undefined) ? value.toString() : ''; } module.exports = UINode; From dd2b39979266975e4559163a63dac9bad8bfa503 Mon Sep 17 00:00:00 2001 From: Grant Date: Tue, 29 Sep 2020 13:21:38 +0100 Subject: [PATCH 3/3] undo original fix --- lib/node.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/node.js b/lib/node.js index 9c6891a..a9eb4da 100644 --- a/lib/node.js +++ b/lib/node.js @@ -45,15 +45,12 @@ function UINode(view) { this.instance = view; keepViewsAlive(); - const handle = view.handle; - if (handle !== null && handle !== undefined) { - const activeKey = handle.toString(); - if (!(activeKey in activeInstances)) { - view.retain(); - activeInstances[activeKey] = new Set([this]); - } else { - activeInstances[activeKey].add(this); - } + const activeKey = view.handle.toString(); + if (!(activeKey in activeInstances)) { + view.retain(); + activeInstances[activeKey] = new Set([this]); + } else { + activeInstances[activeKey].add(this); } if (UIWebViewClass === null) {