aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2018-10-12 17:12:02 +0200
committerErlang/OTP <[email protected]>2018-10-12 17:12:02 +0200
commit096742f3a7d73a9ded87e996422cb566b4d42384 (patch)
tree1bf09125f7e079a96039765acf47b99c66994287 /erts
parent377f19f25aeec6939a6728bd0c4910086c22ccdc (diff)
parent167546a639b64691489615b91947749606e71987 (diff)
downloadotp-096742f3a7d73a9ded87e996422cb566b4d42384.tar.gz
otp-096742f3a7d73a9ded87e996422cb566b4d42384.tar.bz2
otp-096742f3a7d73a9ded87e996422cb566b4d42384.zip
Merge branch 'john/erts/fix-prim_file-error-leak/OTP-15318' into maint-21
* john/erts/fix-prim_file-error-leak/OTP-15318: erts: Fix memory leak on file read errors
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/nifs/common/prim_file_nif.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/erts/emulator/nifs/common/prim_file_nif.c b/erts/emulator/nifs/common/prim_file_nif.c
index a05d50b333..fd6aaa61f6 100644
--- a/erts/emulator/nifs/common/prim_file_nif.c
+++ b/erts/emulator/nifs/common/prim_file_nif.c
@@ -514,6 +514,7 @@ static ERL_NIF_TERM read_nif_impl(efile_data_t *d, ErlNifEnv *env, int argc, con
ASSERT(bytes_read <= block_size);
if(bytes_read < 0) {
+ enif_release_binary(&result);
return posix_error_to_tuple(env, d->posix_errno);
} else if(bytes_read == 0) {
enif_release_binary(&result);
@@ -576,6 +577,7 @@ static ERL_NIF_TERM pread_nif_impl(efile_data_t *d, ErlNifEnv *env, int argc, co
bytes_read = efile_preadv(d, offset, read_vec, 1);
if(bytes_read < 0) {
+ enif_release_binary(&result);
return posix_error_to_tuple(env, d->posix_errno);
} else if(bytes_read == 0) {
enif_release_binary(&result);
@@ -802,6 +804,7 @@ static ERL_NIF_TERM ipread_s32bu_p32bu_nif_impl(efile_data_t *d, ErlNifEnv *env,
bytes_read = efile_preadv(d, payload_offset, read_vec, 1);
if(bytes_read < 0) {
+ enif_release_binary(&payload);
return posix_error_to_tuple(env, d->posix_errno);
} else if(bytes_read == 0) {
enif_release_binary(&payload);