Add support for non-byte-aligned bitstrings#2357
Conversation
PR Review —
|
7733d77 to
d0cfee6
Compare
Follow-up PR Review —
|
A dynamic segment size comes from a register and can be negative. It was scaled by the segment unit before being validated, so the scaled value could wrap to a small size that passed the capacity check and matched, or move the match state offset before the start of the binary. The JIT also untagged small integers with a logical shift, which turned any negative integer into a large positive one. Signed-off-by: Paul Guyot <pguyot@kallisys.net>
Also drop the unreachable register-size case of the bs_match integer command in the JIT and interpreter, and remove the now-unused term_bs_insert_binary. Signed-off-by: Paul Guyot <pguyot@kallisys.net>
| // second reservation would leave the earlier ones dangling. | ||
| size_t heap_size = 3 * TERM_BOXED_SUB_BINARY_SIZE + 3 * term_binary_heap_size(1) | ||
| + 2 * term_binary_heap_size(2); | ||
| assert(memory_ensure_free(ctx, heap_size) == MEMORY_GC_OK); |
These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later