aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2018-12-06 14:24:06 +0100
committerMicael Karlberg <[email protected]>2018-12-06 14:24:06 +0100
commitc5378517cccf29d1708c71a0949664605743b478 (patch)
treef14aecc1b9ad10f1e7306618e62bbb4666dc1a60
parent7923c2c7ce4deba75d845501eb96ddce07dc5ea0 (diff)
downloadotp-c5378517cccf29d1708c71a0949664605743b478.tar.gz
otp-c5378517cccf29d1708c71a0949664605743b478.tar.bz2
otp-c5378517cccf29d1708c71a0949664605743b478.zip
[socket-nif] Valgrind: plugged memory leaks in nif_[recvfrom<recvmsg]
"Dry fixed" the "same" problems as was found for nif_recv (missing binary free(s)). OTP-14831
-rw-r--r--erts/emulator/nifs/common/socket_nif.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c
index 57ce92d77e..1e0533535c 100644
--- a/erts/emulator/nifs/common/socket_nif.c
+++ b/erts/emulator/nifs/common/socket_nif.c
@@ -13883,6 +13883,8 @@ ERL_NIF_TERM recvfrom_check_result(ErlNifEnv* env,
(ERL_NIF_SELECT_STOP),
descP, NULL, recvRef);
+ FREE_BIN(bufP);
+
return res;
} else if ((saveErrno == ERRNO_BLOCK) ||
@@ -13896,7 +13898,10 @@ ERL_NIF_TERM recvfrom_check_result(ErlNifEnv* env,
SELECT(env, descP->sock, (ERL_NIF_SELECT_READ),
descP, NULL, recvRef);
+ FREE_BIN(bufP);
+
return esock_make_error(env, esock_atom_eagain);
+
} else {
ERL_NIF_TERM res = esock_make_error_errno(env, saveErrno);
@@ -13906,6 +13911,8 @@ ERL_NIF_TERM recvfrom_check_result(ErlNifEnv* env,
recv_error_current_reader(env, descP, res);
+ FREE_BIN(bufP);
+
return res;
}
@@ -13983,6 +13990,9 @@ ERL_NIF_TERM recvmsg_check_result(ErlNifEnv* env,
* *We* do never actually try to read 0 bytes from a stream socket!
*/
+
+ FREE_BIN(dataBufP); FREE_BIN(ctrlBufP);
+
return esock_make_error(env, atom_closed);
}
@@ -14023,6 +14033,8 @@ ERL_NIF_TERM recvmsg_check_result(ErlNifEnv* env,
(ERL_NIF_SELECT_STOP),
descP, NULL, recvRef);
+ FREE_BIN(dataBufP); FREE_BIN(ctrlBufP);
+
return res;
} else if ((saveErrno == ERRNO_BLOCK) ||
@@ -14037,7 +14049,10 @@ ERL_NIF_TERM recvmsg_check_result(ErlNifEnv* env,
SELECT(env, descP->sock, (ERL_NIF_SELECT_READ),
descP, NULL, recvRef);
+ FREE_BIN(dataBufP); FREE_BIN(ctrlBufP);
+
return esock_make_error(env, esock_atom_eagain);
+
} else {
ERL_NIF_TERM res = esock_make_error_errno(env, saveErrno);
@@ -14047,6 +14062,8 @@ ERL_NIF_TERM recvmsg_check_result(ErlNifEnv* env,
recv_error_current_reader(env, descP, res);
+ FREE_BIN(dataBufP); FREE_BIN(ctrlBufP);
+
return res;
}
@@ -14078,6 +14095,8 @@ ERL_NIF_TERM recvmsg_check_result(ErlNifEnv* env,
recv_update_current_reader(env, descP);
+ FREE_BIN(dataBufP); FREE_BIN(ctrlBufP);
+
return esock_make_error_str(env, xres);
} else {