[anjuta/gnome-3-0] symbol-db: fixed memory leak on ctags pointed out by Matthew Brush



commit 8fcdb852552314f1c105661616754f713db07ed5
Author: Massimo Corà <mcora src gnome org>
Date:   Thu Jun 2 01:29:08 2011 +0200

    symbol-db: fixed memory leak on ctags pointed out by Matthew Brush

 plugins/symbol-db/readtags.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/plugins/symbol-db/readtags.c b/plugins/symbol-db/readtags.c
index 371a02e..f1b0d95 100644
--- a/plugins/symbol-db/readtags.c
+++ b/plugins/symbol-db/readtags.c
@@ -450,6 +450,14 @@ static tagFile *initialize (const char *const filePath, tagFileInfo *const info)
 		result->fp = fopen (filePath, "r");
 		if (result->fp == NULL)
 		{
+			/* free the result struct */
+			if (result->fields.list)
+				free (result->fields.list);
+			if (result->line.buffer)
+				free (result->line.buffer);
+			if (result->name.buffer)
+				free (result->name.buffer);
+
 			free (result);
 			result = NULL;
 			info->status.error_number = errno;
@@ -481,6 +489,14 @@ static tagFile *initialize_1 (const FILE* fd, tagFileInfo *const info)
 		result->fp = (FILE*)fd;
 		if (result->fp == NULL)
 		{
+			/* free the result struct */
+			if (result->fields.list)
+				free (result->fields.list);
+			if (result->line.buffer)
+				free (result->line.buffer);
+			if (result->name.buffer)
+				free (result->name.buffer);
+
 			free (result);
 			result = NULL;
 			info->status.error_number = errno;



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