Previously, when JS_EnqueueJob() failed, the cleanup freed the
original result argument instead of the job arguments. For a
rejected result, that argument is JS_EXCEPTION, while the reason
taken with JS_GetException() leaked.
Free the job arguments, which own the callback and the reason or
result value in both cases.
The issue was introduced in
87086636 (0.8.10).
if (JS_EnqueueJob(cx, qjs_promise_fill_trampoline, 2, arguments) < 0) {
JS_FreeValue(cx, promise);
- JS_FreeValue(cx, callbacks[is_error]);
- JS_FreeValue(cx, result);
+ JS_FreeValue(cx, arguments[0]);
+ JS_FreeValue(cx, arguments[1]);
return JS_EXCEPTION;
}