[PATCH 04/13] Plug memory leaks in compare_samples

Anton Lundin glance at acc.umu.se
Tue Dec 10 15:53:28 UTC 2013


Free temporary buffer before returning.

Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 profile.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/profile.c b/profile.c
index 5c77e60..ed55037 100644
--- a/profile.c
+++ b/profile.c
@@ -1344,8 +1344,10 @@ void compare_samples(struct plot_data *e1, struct plot_data *e2, char *buf, int
 
 	if (bufsize > 0)
 		buf[0] = '\0';
-	if (e1 == NULL || e2 == NULL)
+	if (e1 == NULL || e2 == NULL) {
+		free(buf2);
 		return;
+	}
 
 	if (e1->sec < e2->sec) {
 		start = e1;
@@ -1354,6 +1356,7 @@ void compare_samples(struct plot_data *e1, struct plot_data *e2, char *buf, int
 		start = e2;
 		stop = e1;
 	} else {
+		free(buf2);
 		return;
 	}
 	count = 0;
-- 
1.8.3.2



More information about the subsurface mailing list