Fix null pointer dereference
Commit Message
This restores the check that demangle is non-null, that was removed
(inadvertently, I suppose) by commit
43816ebc335481c99808c4fdfffb9ea3f510b19a.
gdb/ChangeLog
2020-02-21 Ruslan Kabatsayev <b7.10110111@gmail.com>
* dwarf2/read.c (dwarf2_name): Fix null pointer dereference
---
gdb/dwarf2/read.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
Comments
On 2020-02-21 1:35 a.m., Ruslan Kabatsayev wrote:
> This restores the check that demangle is non-null, that was removed
> (inadvertently, I suppose) by commit
> 43816ebc335481c99808c4fdfffb9ea3f510b19a.
>
> gdb/ChangeLog
> 2020-02-21 Ruslan Kabatsayev <b7.10110111@gmail.com>
>
> * dwarf2/read.c (dwarf2_name): Fix null pointer dereference
> ---
> gdb/dwarf2/read.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index f998fe6b8d0..1fd5f55a534 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -21752,11 +21752,12 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
>
> /* Avoid demangling DW_STRING (attr) the second time on a second
> call for the same DIE. */
> + gdb::unique_xmalloc_ptr<char> demangled;
> if (!DW_STRING_IS_CANONICAL (attr))
> - {
> - gdb::unique_xmalloc_ptr<char> demangled
> - (gdb_demangle (DW_STRING (attr), DMGL_TYPES));
> + demangled.reset (gdb_demangle (DW_STRING (attr), DMGL_TYPES));
>
> + if (demangled)
> + {
> const char *base;
>
> /* FIXME: we already did this for the partial symbol... */
> --
> 2.16.2
>
Hi Ruslan,
This patch here fixes the same issue, I believe:
https://sourceware.org/ml/gdb-patches/2020-02/msg00490.html
It should be committed soon.
Simon
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
Simon> This patch here fixes the same issue, I believe:
Simon> https://sourceware.org/ml/gdb-patches/2020-02/msg00490.html
Simon> It should be committed soon.
I went ahead and pushed it.
Tom
@@ -21752,11 +21752,12 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
/* Avoid demangling DW_STRING (attr) the second time on a second
call for the same DIE. */
+ gdb::unique_xmalloc_ptr<char> demangled;
if (!DW_STRING_IS_CANONICAL (attr))
- {
- gdb::unique_xmalloc_ptr<char> demangled
- (gdb_demangle (DW_STRING (attr), DMGL_TYPES));
+ demangled.reset (gdb_demangle (DW_STRING (attr), DMGL_TYPES));
+ if (demangled)
+ {
const char *base;
/* FIXME: we already did this for the partial symbol... */