mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
Fix memory leak if an exception is thrown within a rejected promise
This commit is contained in:
parent
94d5063aa9
commit
61585f7069
@ -5,6 +5,8 @@
|
||||
Pixl.js: Reorder pins so 0..13 are also D0..13 for better Arduino compatibility
|
||||
Fix dump() when used with code written using E.setBootCode(..), (fix #1398)
|
||||
Allow parseInt/parseFloat to be used on very large strings if the number doesn't extend right to the end (fix #1397)
|
||||
nRF5x: Fix memory leak on NRF.connect
|
||||
Fix memory leak if an exception is thrown within a rejected promise
|
||||
|
||||
1v97 : nRF52: fix NRF.on('connect',...) issue
|
||||
STM32: Fix setDeviceClockCmd error for USB.setConsole()
|
||||
|
||||
@ -73,7 +73,7 @@ void _jswrap_promise_resolve_or_reject(JsVar *promise, JsVar *data, JsVar *fn) {
|
||||
JsVar *exception = jspGetException();
|
||||
if (exception) {
|
||||
_jswrap_promise_queuereject(chainedPromise, exception);
|
||||
jsvUnLock2(result, chainedPromise);
|
||||
jsvUnLock3(exception, result, chainedPromise);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
12
tests/test_promise10.js
Normal file
12
tests/test_promise10.js
Normal file
@ -0,0 +1,12 @@
|
||||
function test() {
|
||||
(new Promise(function(resolve,reject){
|
||||
reject("Oh No!");
|
||||
})).then(function(x) {
|
||||
console.log("Ok");
|
||||
}).catch(function() {
|
||||
console.log("Fail (expected)");
|
||||
result=1;
|
||||
throw "This used to leak memory!";
|
||||
});
|
||||
}
|
||||
test(); // it used to fail here
|
||||
@ -2,10 +2,10 @@
|
||||
function test() {
|
||||
if (busy) return;
|
||||
(new Promise(function(go){go(1)})).then(function(x) {
|
||||
console("Ok");
|
||||
console.log("Ok");
|
||||
result = x;
|
||||
}).catch(function() {
|
||||
console("Fail");
|
||||
console.log("Fail");
|
||||
});
|
||||
}
|
||||
var busy = true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user