1 From d8a94684e2a9a584080757a324c4c42183f6d11a Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Laban?= <jerome.laban@nventive.com>
3 Date: Mon, 29 Apr 2019 11:54:21 -0400
4 Subject: [PATCH] Invalid double dlopen failure fix
8 src/support.js | 27 ++++++++++++++++++++++-----
9 tests/test_browser.py | 10 ++++++++++
10 2 files changed, 32 insertions(+), 5 deletions(-)
12 diff --git a/src/support.js b/src/support.js
13 index 68360e406..419e4cbb5 100644
16 @@ -302,14 +302,31 @@ function loadDynamicLibrary(lib, flags) {
17 dso.module = libModule;supp
20 + function cleanupOnError() {
21 + var lib_record = LDSO.loadedLibs[handle];
22 + delete LDSO.loadedLibNames[lib_record.name];
23 + delete LDSO.loadedLibs[handle];
26 if (flags.loadAsync) {
27 - return getLibModule().then(function(libModule) {
28 - moduleLoaded(libModule);
31 + return getLibModule()
32 + .catch(function (e) {
36 + .then(function (libModule) {
37 + moduleLoaded(libModule);
42 - moduleLoaded(getLibModule());
44 + moduleLoaded(getLibModule());
53 diff --git a/tests/test_browser.py b/tests/test_browser.py
54 index 7836141db..eeb7ad2ff 100644
55 --- a/tests/test_browser.py
56 +++ b/tests/test_browser.py
57 @@ -2408,6 +2408,16 @@ void *getBindBuffer() {
61 + void *invalid_handle = dlopen("/invalid.so", 0);
62 + if (invalid_handle) {
66 + void *invalid_handle2 = dlopen("/invalid.so", 0);
67 + if (invalid_handle2) {