Skip to content

Commit

Permalink
Modules: adding NUL byte at the end of the module body.
Browse files Browse the repository at this point in the history
Even though QuickJS takes length as an argument, when parsing the code,
it expects NUL byte at the end.
  • Loading branch information
xeioex committed Jun 29, 2024
1 parent 8c7ade4 commit 184d2a3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion nginx/ngx_js.c
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,7 @@ ngx_js_module_read(njs_mp_t *mp, int fd, njs_str_t *text)

text->length = sb.st_size;

text->start = njs_mp_alloc(mp, text->length);
text->start = njs_mp_alloc(mp, text->length + 1);
if (text->start == NULL) {
goto fail;
}
Expand All @@ -1852,6 +1852,8 @@ ngx_js_module_read(njs_mp_t *mp, int fd, njs_str_t *text)
goto fail;
}

text->start[text->length] = '\0';

return NJS_OK;

fail:
Expand Down

0 comments on commit 184d2a3

Please sign in to comment.