This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 31/40] fix source.c
- From: Tom Tromey <tromey at redhat dot com>
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 09 May 2013 12:52:10 -0600
- Subject: [PATCH 31/40] fix source.c
- References: <cover dot 1368124285 dot git dot tromey at redhat dot com>
find_and_open_source can leak a cleanup.
* source.c (find_and_open_source): Call do_cleanups.
---
gdb/source.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gdb/source.c b/gdb/source.c
index 161a6c4..71b6d53 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -985,6 +985,7 @@ find_and_open_source (const char *filename,
char *path = source_path;
const char *p;
int result;
+ struct cleanup *cleanup;
/* Quick way out if we already know its full name. */
@@ -1016,6 +1017,8 @@ find_and_open_source (const char *filename,
*fullname = NULL;
}
+ cleanup = make_cleanup (null_cleanup, NULL);
+
if (dirname != NULL)
{
/* If necessary, rewrite the compilation directory name according
@@ -1072,6 +1075,7 @@ find_and_open_source (const char *filename,
result = openp (path, OPF_SEARCH_IN_PATH, p, OPEN_MODE, fullname);
}
+ do_cleanups (cleanup);
return result;
}
--
1.8.1.4