[PATCH lksctp-tools 4/5] fix memory leak of iov.iov_base

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Qiumiao Zhang <zhangqiumiao1@xxxxxxxxxx>
---
 src/apps/sctp_darn.c                  | 4 ++++
 src/func_tests/test_sctp_sendvrecvv.c | 1 +
 2 files changed, 5 insertions(+)

diff --git a/src/apps/sctp_darn.c b/src/apps/sctp_darn.c
index d7dcc73..b909d26 100644
--- a/src/apps/sctp_darn.c
+++ b/src/apps/sctp_darn.c
@@ -676,6 +676,7 @@ command_listen(char *argv0, int sk)
 				if ((recvsk = accept(sk, NULL, &len)) < 0) {
 					fprintf(stderr, "%s: error: %s.\n",
 						argv0, strerror(errno));
+					free(iov.iov_base);
 					exit(1);
 				}
 			}
@@ -716,6 +717,7 @@ command_listen(char *argv0, int sk)
 					   sizeof(msgname)) == -1) {
 					fprintf(stderr, "%s: error: %s.\n",
 						argv0, strerror(errno));
+					free(iov.iov_base);
 					exit(1);
 				}
 			}
@@ -739,6 +741,8 @@ command_listen(char *argv0, int sk)
 		}
 	}

+	free(iov.iov_base);
+
 	if (error < 0) {
 		fprintf(stderr, "%s: error: %s.\n",
 			argv0, strerror(errno));
diff --git a/src/func_tests/test_sctp_sendvrecvv.c b/src/func_tests/test_sctp_sendvrecvv.c
index 56ea20a..9dfb2cd 100644
--- a/src/func_tests/test_sctp_sendvrecvv.c
+++ b/src/func_tests/test_sctp_sendvrecvv.c
@@ -265,6 +265,7 @@ int main(int argc, char *argv[])

 	close(sk1);
 	close(sk2);
+	free(iov.iov_base);

 	return 0;
 }
--
2.27.0




[Index of Archives]     [Linux Networking Development]     [Linux OMAP]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     SCTP

  Powered by Linux