Skip to content

Commit 507345f

Browse files
committed
Merge pull request #1717 from jgonet/jgonet/term-debug-assert
Fix term asserts 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 1e55abd + 435d16d commit 507345f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/libAtomVM/memory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ void memory_sweep_mso_list(term mso_list, GlobalContext *global, bool from_task)
961961
while (l != term_nil()) {
962962
term h = term_get_list_head(l);
963963
// the mso list only contains boxed values; each refc is unique
964-
TERM_DEBUG_ASSERT(term_is_boxed(h))
964+
TERM_DEBUG_ASSERT(term_is_boxed(h));
965965
term *boxed_value = term_to_term_ptr(h);
966966
if (memory_is_moved_marker(boxed_value)) {
967967
h = memory_dereference_moved_marker(boxed_value);

src/libAtomVM/term.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,7 +1683,7 @@ static inline void term_put_tuple_element(term t, uint32_t elem_index, term put_
16831683

16841684
term *boxed_value = term_to_term_ptr(t);
16851685

1686-
TERM_DEBUG_ASSERT(((boxed_value[0] & TERM_BOXED_TAG_MASK) == 0) && (elem_index < (boxed_value[0] >> 6)));
1686+
TERM_DEBUG_ASSERT((size_t) elem_index < term_get_size_from_boxed_header(boxed_value[0]));
16871687

16881688
boxed_value[elem_index + 1] = put_value;
16891689
}
@@ -1702,7 +1702,7 @@ static inline term term_get_tuple_element(term t, int elem_index)
17021702

17031703
const term *boxed_value = term_to_const_term_ptr(t);
17041704

1705-
TERM_DEBUG_ASSERT(((boxed_value[0] & TERM_BOXED_TAG_MASK) == 0) && (elem_index < (boxed_value[0] >> 6)));
1705+
TERM_DEBUG_ASSERT((size_t) elem_index < term_get_size_from_boxed_header(boxed_value[0]));
17061706

17071707
return boxed_value[elem_index + 1];
17081708
}

0 commit comments

Comments
 (0)