From 758804ae31d778840699ac0fe8eab9e20ecda5af Mon Sep 17 00:00:00 2001
From: Michael Tuexen <tuexen@fh-muenster.de>
Date: Fri, 12 Oct 2018 17:26:01 +0200
Subject: [PATCH] Plumb TCP related memory leaks.

---
 gtests/net/packetdrill/tcp_options.c | 1 +
 gtests/net/packetdrill/tcp_packet.c  | 3 ++-
 gtests/net/packetdrill/tcp_packet.h  | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/gtests/net/packetdrill/tcp_options.c b/gtests/net/packetdrill/tcp_options.c
index 2998c312..b7def9db 100644
--- a/gtests/net/packetdrill/tcp_options.c
+++ b/gtests/net/packetdrill/tcp_options.c
@@ -49,6 +49,7 @@ int tcp_options_append(struct tcp_options *options,
 	memcpy(options->data + options->length, option, option->length);
 	options->length += option->length;
 	assert(options->length <= sizeof(options->data));
+	free(option);
 	return STATUS_OK;
 }
 
diff --git a/gtests/net/packetdrill/tcp_packet.c b/gtests/net/packetdrill/tcp_packet.c
index 1292b597..fc32605c 100644
--- a/gtests/net/packetdrill/tcp_packet.c
+++ b/gtests/net/packetdrill/tcp_packet.c
@@ -58,7 +58,7 @@ struct packet *new_tcp_packet(int address_family,
 			       u16 tcp_payload_bytes,
 			       u32 ack_sequence,
 			       s32 window,
-			       const struct tcp_options *tcp_options,
+			       struct tcp_options *tcp_options,
 			       bool ignore_ts_val,
 			       bool abs_ts_ecr,
 			       bool abs_seq,
@@ -182,6 +182,7 @@ struct packet *new_tcp_packet(int address_family,
 		/* Copy TCP options into packet */
 		memcpy(tcp_option_start, tcp_options->data,
 		       tcp_options->length);
+		free(tcp_options);
 	}
 
 	if (ignore_ts_val) {
diff --git a/gtests/net/packetdrill/tcp_packet.h b/gtests/net/packetdrill/tcp_packet.h
index 1a9115cd..4a2947a7 100644
--- a/gtests/net/packetdrill/tcp_packet.h
+++ b/gtests/net/packetdrill/tcp_packet.h
@@ -43,7 +43,7 @@ extern struct packet *new_tcp_packet(int address_family,
 				     u16 tcp_payload_bytes,
 				     u32 ack_sequence,
 				     s32 window,
-				     const struct tcp_options *tcp_options,
+				     struct tcp_options *tcp_options,
 				     bool ignore_ts_val,
 				     bool abs_ts_ecr,
 				     bool abs_seq,
-- 
GitLab