aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2011-09-19 19:01:40 +0000
committerDoug Evans <dje@google.com>2011-09-19 19:01:40 +0000
commit562f943bccc5f35b000983a1aa9f9a8af7b3cad0 (patch)
tree098c1a94f04ce0dd792178951dc80ddef06ed6e2
parent3c9057f3816867fcf94bec3e264c2b7b0873fd29 (diff)
downloadfsf-binutils-gdb-562f943bccc5f35b000983a1aa9f9a8af7b3cad0.zip
fsf-binutils-gdb-562f943bccc5f35b000983a1aa9f9a8af7b3cad0.tar.gz
fsf-binutils-gdb-562f943bccc5f35b000983a1aa9f9a8af7b3cad0.tar.bz2
* python/py-auto-load.c (source_section_scripts): Fix file
descriptor leak. * python/python.c (source_python_script_for_objfile): Tweak comments.
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/python/py-auto-load.c16
-rw-r--r--gdb/python/python.c7
3 files changed, 18 insertions, 11 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 053c6ef..1b2519b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2011-09-19 Doug Evans <dje@google.com>
+
+ * python/py-auto-load.c (source_section_scripts): Fix file
+ descriptor leak.
+ * python/python.c (source_python_script_for_objfile): Tweak comments.
+
2011-09-18 Yao Qi <yao@codesourcery.com>
Ulrich Weigand <ulrich.weigand@linaro.org>
diff --git a/gdb/python/py-auto-load.c b/gdb/python/py-auto-load.c
index 158b1cb..75fa041 100644
--- a/gdb/python/py-auto-load.c
+++ b/gdb/python/py-auto-load.c
@@ -296,9 +296,6 @@ source_section_scripts (struct objfile *objfile, const char *source_name,
in_hash_table = maybe_add_script (pspace_info->loaded_scripts, file,
opened ? full_path : NULL);
- if (opened)
- free (full_path);
-
if (! opened)
{
/* We don't throw an error, the program is still debuggable. */
@@ -310,12 +307,15 @@ Use `info auto-load-scripts [REGEXP]' to list them."),
GDBPY_AUTO_SECTION_NAME, objfile->name);
pspace_info->script_not_found_warning_printed = TRUE;
}
- continue;
}
-
- /* If this file is not currently loaded, load it. */
- if (! in_hash_table)
- source_python_script_for_objfile (objfile, stream, file);
+ else
+ {
+ /* If this file is not currently loaded, load it. */
+ if (! in_hash_table)
+ source_python_script_for_objfile (objfile, stream, file);
+ fclose (stream);
+ free (full_path);
+ }
}
}
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 67649c3..4ef5715 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -903,7 +903,10 @@ gdbpy_progspaces (PyObject *unused1, PyObject *unused2)
static struct objfile *gdbpy_current_objfile;
/* Set the current objfile to OBJFILE and then read STREAM,FILE as
- Python code. */
+ Python code.
+ STREAM is left open, it is up to the caller to close it.
+ If an exception occurs python will print the traceback and
+ clear the error indicator. */
void
source_python_script_for_objfile (struct objfile *objfile,
@@ -914,8 +917,6 @@ source_python_script_for_objfile (struct objfile *objfile,
cleanups = ensure_python_env (get_objfile_arch (objfile), current_language);
gdbpy_current_objfile = objfile;
- /* Note: If an exception occurs python will print the traceback and
- clear the error indicator. */
PyRun_SimpleFile (stream, file);
do_cleanups (cleanups);