Skip to content

Commit ebef40d

Browse files
committed
Add missing memory_ensure_free in nif_openssl_random
Signed-off-by: Paul Guyot <[email protected]>
1 parent b147b31 commit ebef40d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/platforms/generic_unix/lib/platform_nifs.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ static term nif_openssl_random(Context *ctx, int argc, term argv[])
100100
return t;
101101
}
102102
uint32_t *r = (uint32_t *) term_binary_data(t);
103-
return term_make_boxed_int(*r, ctx);
103+
avm_int_t value = *r;
104+
if (UNLIKELY(memory_ensure_free(ctx, BOXED_INT_SIZE) != MEMORY_GC_OK)) {
105+
RAISE_ERROR(OUT_OF_MEMORY_ATOM);
106+
}
107+
return term_make_boxed_int(value, ctx);
104108
}
105109

106110
static const struct Nif openssl_md5_nif =

0 commit comments

Comments
 (0)