Skip to content

Commit c75f35b

Browse files
committed
Merge pull request #1689 from bettio/literal-remove-abort
module: do not abort when OOM while loading literal 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 42d2944 + 4f368c1 commit c75f35b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ memory error
6767
- Fixed nif_atomvm_posix_read GC bug
6868
- Fixed `erlang:is_number/1` function, now returns true also for floats
6969
- Fixed unlink protocol and add support for `link/1` on ports
70+
- Do not abort when an out of memory happens while loading a literal value
7071

7172
### Changed
7273

src/libAtomVM/module.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,8 @@ term module_load_literal(Module *mod, int index, Context *ctx)
426426
{
427427
term t = externalterm_to_term(mod->literals_table[index].data, mod->literals_table[index].size,
428428
ctx, ExternalTermToHeapFragment);
429-
if (term_is_invalid_term(t)) {
430-
fprintf(stderr, "Invalid term reading literals_table[%i] from module\n", index);
431-
AVM_ABORT();
429+
if (UNLIKELY(term_is_invalid_term(t))) {
430+
fprintf(stderr, "Either OOM or invalid term while reading literals_table[%i] from module\n", index);
432431
}
433432
return t;
434433
}

0 commit comments

Comments
 (0)