From: Dmitry Volyntsev Date: Wed, 19 Jun 2024 06:47:31 +0000 (-0700) Subject: Modules: adding NUL byte at the end of the module body. X-Git-Tag: 0.8.6~46 X-Git-Url: http://www.kaiwu.me/postgresql/commit/static/gitweb.js?a=commitdiff_plain;h=184d2a39cb5da696785247439e480f9b2250e99c;p=njs.git Modules: adding NUL byte at the end of the module body. Even though QuickJS takes length as an argument, when parsing the code, it expects NUL byte at the end. --- diff --git a/nginx/ngx_js.c b/nginx/ngx_js.c index ef85096c..b372feca 100644 --- a/nginx/ngx_js.c +++ b/nginx/ngx_js.c @@ -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; } @@ -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: