Skip to content

Add missing null checks for njs_promise_create_function allocations #912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add missing null checks for promise code.
  • Loading branch information
Nekrolm committed May 15, 2025
commit 3d8f3e54d87a9903cdc3eae3017e4ba6e7f77266
9 changes: 9 additions & 0 deletions src/njs_promise.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ njs_promise_trigger_reactions(njs_vm_t *vm, njs_value_t *value,

function = njs_promise_create_function(vm,
sizeof(njs_promise_context_t));
if (njs_slow_path(function == NULL)) {
return njs_value_arg(&njs_value_null);
}

function->u.native = njs_promise_reaction_job;

njs_set_data(&arguments[0], reaction, 0);
Expand Down Expand Up @@ -784,6 +788,11 @@ njs_promise_prototype_then(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
}

function = njs_promise_create_function(vm, sizeof(njs_promise_context_t));
if (njs_slow_path(function == NULL)) {
/* vm error is already set by njs_promise_create_function */
return NJS_ERROR;
}

function->u.native = njs_promise_constructor;

njs_set_function(&constructor, function);
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy