diff options
author | Tom Tromey <tromey@adacore.com> | 2019-07-01 09:33:19 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2019-07-01 09:36:30 -0600 |
commit | 54ee425275c759438d90c40781e3810a551f0a5f (patch) | |
tree | 5cdc2e373b514b596fe39800d09fb41a7f6198ac /gdb/dwarf2read.c | |
parent | 269b4ded72af1fa05236f866b518f05cf2d408a6 (diff) | |
download | gdb-54ee425275c759438d90c40781e3810a551f0a5f.zip gdb-54ee425275c759438d90c40781e3810a551f0a5f.tar.gz gdb-54ee425275c759438d90c40781e3810a551f0a5f.tar.bz2 |
Avoid use-after-free in DWARF debug names code
A static analyzer pointed out that find_vec_in_debug_names will use
the contents of a unique_ptr after it has been destroyed. This patch
fixes the bug by hoisting the declaration into the appropriate
enclosing block.
I'm checking this in as obvious.
gdb/ChangeLog
2019-07-01 Tom Tromey <tromey@adacore.com>
* dwarf2read.c
(dw2_debug_names_iterator::find_vec_in_debug_names): Hoist
declaration of without_params. Fix formatting.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r-- | gdb/dwarf2read.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index d004863..f1fbba4 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -5726,6 +5726,7 @@ dw2_debug_names_iterator::find_vec_in_debug_names { int (*cmp) (const char *, const char *); + gdb::unique_xmalloc_ptr<char> without_params; if (current_language->la_language == language_cplus || current_language->la_language == language_fortran || current_language->la_language == language_d) @@ -5735,13 +5736,9 @@ dw2_debug_names_iterator::find_vec_in_debug_names if (strchr (name, '(') != NULL) { - gdb::unique_xmalloc_ptr<char> without_params - = cp_remove_params (name); - + without_params = cp_remove_params (name); if (without_params != NULL) - { - name = without_params.get(); - } + name = without_params.get (); } } |