Skip to content

Commit 9c2b9db

Browse files
committed
Fixed missed allocation check in promise code.
Found by Coverity (CID 1646931, 1646932).
1 parent bd04119 commit 9c2b9db

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/njs_promise.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,10 @@ njs_promise_perform_then(njs_vm_t *vm, njs_value_t *value,
876876
} else {
877877
function = njs_promise_create_function(vm,
878878
sizeof(njs_promise_context_t));
879+
if (njs_slow_path(function == NULL)) {
880+
return NJS_ERROR;
881+
}
882+
879883
function->u.native = njs_promise_reaction_job;
880884

881885
if (data->state == NJS_PROMISE_REJECTED) {
@@ -967,6 +971,10 @@ njs_promise_prototype_finally(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
967971
finally = njs_arg(args, nargs, 1);
968972

969973
function = njs_promise_create_function(vm, sizeof(njs_promise_context_t));
974+
if (njs_slow_path(function == NULL)) {
975+
return NJS_ERROR;
976+
}
977+
970978
function->u.native = njs_promise_constructor;
971979

972980
njs_set_function(&constructor, function);

0 commit comments

Comments
 (0)