[PATCH 05/13] Plug potential memory leak in process_raw_buffer

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


Free temporary buffer before returning.

Signed-off-by: Anton Lundin <glance at acc.umu.se>
---
 uemis-downloader.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/uemis-downloader.c b/uemis-downloader.c
index e8e24b7..b1d977d 100644
--- a/uemis-downloader.c
+++ b/uemis-downloader.c
@@ -644,15 +644,20 @@ static void process_raw_buffer(uint32_t deviceid, char *inbuf, char **max_divenr
 		/* this is a divelog */
 		log = TRUE;
 		tp = next_token(&bp);
-		if (strcmp(tp,"1.0") != 0)
+		if (strcmp(tp,"1.0") != 0) {
+			free(buf);
 			return;
+		}
 	} else if (strcmp(tp, "dive") == 0) {
 		/* this is dive detail */
 		tp = next_token(&bp);
-		if (strcmp(tp,"1.0") != 0)
+		if (strcmp(tp,"1.0") != 0) {
+			free(buf);
 			return;
+		}
 	} else {
 		/* don't understand the buffer */
+		free(buf);
 		return;
 	}
 	if (log)
-- 
1.8.3.2



More information about the subsurface mailing list