fix source.c
authorTom Tromey <tromey@redhat.com>
Thu, 30 May 2013 17:33:41 +0000 (17:33 +0000)
committerTom Tromey <tromey@redhat.com>
Thu, 30 May 2013 17:33:41 +0000 (17:33 +0000)
find_and_open_source can leak a cleanup.

* source.c (find_and_open_source): Call do_cleanups.

gdb/ChangeLog
gdb/source.c

index c2eb3bb8bdbe4a4cd2d227a9433b74168fa28c56..080275e1deec28a346463e7aed51be55231b2cf7 100644 (file)
@@ -1,3 +1,7 @@
+2013-05-30  Tom Tromey  <tromey@redhat.com>
+
+       * source.c (find_and_open_source): Call do_cleanups.
+
 2013-05-30  Tom Tromey  <tromey@redhat.com>
 
        * linux-thread-db.c (thread_db_load_search): Unconditionally
index 161a6c43d028f131a0e0b0cf5c7773ffbab38bed..71b6d53b502e0ecba55f9c9955fc043900ab9d91 100644 (file)
@@ -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;
 }