Skip to content

Commit 849fcd6

Browse files
committed
ESP32/NVS: fix memory allocation
Use term_binary_heap_size(size) macro in order to calculate required heap size for binary. Signed-off-by: Davide Bettio <[email protected]>
1 parent 4bdd25b commit 849fcd6

File tree

1 file changed

+1
-1
lines changed
  • src/platforms/esp32/components/avm_builtins

1 file changed

+1
-1
lines changed

src/platforms/esp32/components/avm_builtins/nvs_nif.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static term nif_esp_nvs_get_binary(Context *ctx, int argc, term argv[])
8484
RAISE_ERROR(term_from_int(err));
8585
}
8686

87-
if (UNLIKELY(memory_ensure_free(ctx, size + BINARY_HEADER_SIZE) != MEMORY_GC_OK)) {
87+
if (UNLIKELY(memory_ensure_free(ctx, term_binary_heap_size(size)) != MEMORY_GC_OK)) {
8888
TRACE("Unabled to ensure free space for binary. namespace='%s' key='%s' size=%i\n", namespace, key, size);
8989
RAISE_ERROR(OUT_OF_MEMORY_ATOM);
9090
}

0 commit comments

Comments
 (0)