Skip to content

Commit 8b9419a

Browse files
committed
Merge pull request #1282 from bettio/fix-unicode_characters_to_binary
This PR fixes a memory corruption. 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
2 parents 56f553e + f9e3084 commit 8b9419a

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ instead
2828

2929
- ESP32: content of `boot.avm` partition is not truncated anymore
3030
- ESP32: Fixed gpio:set_int` to accept any pin, not only pin 2
31+
- Fix memory corruption in `unicode:characters_to_binary`
3132

3233
## [0.6.4] - 2024-08-18
3334

src/libAtomVM/nifs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4616,7 +4616,7 @@ static term nif_unicode_characters_to_binary(Context *ctx, int argc, term argv[]
46164616
if (UNLIKELY(conv_result == UnicodeBadArg)) {
46174617
RAISE_ERROR(BADARG_ATOM);
46184618
}
4619-
size_t needed_terms = term_binary_data_size_in_terms(len);
4619+
size_t needed_terms = term_binary_heap_size(len);
46204620
if (UNLIKELY(conv_result == UnicodeError || conv_result == UnicodeIncompleteTransform)) {
46214621
needed_terms += TUPLE_SIZE(3) + rest_size;
46224622
}

0 commit comments

Comments
 (0)