njs through 0.3.1, used in NGINX, has a segmentation fault in String.prototype.toBytes for negative arguments, related to nxt_utf8_next in nxt/nxt_utf8.h and njs_string_offset in njs/njs_string.c.
cpe:2.3:a:f5:njs:*:*:*:*:*:*:*:*
3F70BB50-E3EC-44F8-BC1A-D514EA261742
0.3.1
OR
```js
>> "A".repeat(38).toBytes(-5)
ASAN:SIGSEGV
=================================================================
==16054==ERROR: AddressSanitizer: SEGV on unknown address 0x6090000168e0 (pc 0x00000042c455 bp 0x7fffa72fbb30 sp 0x7fffa72fbaf0 T0)
    #0 0x42c454 in nxt_utf8_next nxt/nxt_utf8.h:44
    #1 0x42c454 in njs_string_offset njs/njs_string.c:2058
    #2 0x4282cd in njs_string_prototype_to_bytes njs/njs_string.c:1047
    #3 0x45f1f2 in njs_function_native_call njs/njs_function.c:587
    #4 0x41bd8f in njs_vmcode_function_call njs/njs_vm.c:2061
    #5 0x413d10 in njs_vmcode_interpreter njs/njs_vm.c:159
    #6 0x412be5 in njs_vm_start njs/njs.c:594
    #7 0x4049a7 in njs_process_script njs/njs_shell.c:770
    #8 0x4037ad in njs_interactive_shell njs/njs_shell.c:500
    #9 0x402a03 in main njs/njs_shell.c:270
```

Minified test from [fluff](https://github.com/Samsung/Fluff) report.
Segfault in String.prototype.toBytes() for negative arguments.
This is a GitHub Issue
repo:njs
owner:nginx
Title : Segfault in String.prototype.toBytes() for negative arguments.
Issue date:

--- start body ---
```js
>> "A".repeat(38).toBytes(-5)
ASAN:SIGSEGV
=================================================================
==16054==ERROR: AddressSanitizer: SEGV on unknown address 0x6090000168e0 (pc 0x00000042c455 bp 0x7fffa72fbb30 sp 0x7fffa72fbaf0 T0)
    #0 0x42c454 in nxt_utf8_next nxt/nxt_utf8.h:44
    #1 0x42c454 in njs_string_offset njs/njs_string.c:2058
    #2 0x4282cd in njs_string_prototype_to_bytes njs/njs_string.c:1047
    #3 0x45f1f2 in njs_function_native_call njs/njs_function.c:587
    #4 0x41bd8f in njs_vmcode_function_call njs/njs_vm.c:2061
    #5 0x413d10 in njs_vmcode_interpreter njs/njs_vm.c:159
    #6 0x412be5 in njs_vm_start njs/njs.c:594
    #7 0x4049a7 in njs_process_script njs/njs_shell.c:770
    #8 0x4037ad in njs_interactive_shell njs/njs_shell.c:500
    #9 0x402a03 in main njs/njs_shell.c:270
```

Minified test from [fluff](https://github.com/Samsung/Fluff) report.
--- end body ---

comments :
--- start comments ---

--- end comments ---