diff options
author | Hannes Domani <ssbssa@yahoo.de> | 2023-12-08 19:06:14 +0100 |
---|---|---|
committer | Hannes Domani <ssbssa@yahoo.de> | 2023-12-08 19:07:50 +0100 |
commit | 576745e26c0ec76a53ba45b20af464628a50b3e4 (patch) | |
tree | 61ba84e9c70d2eb29d59bf23555fbd4d54d71a9a /gdb/cp-namespace.c | |
parent | cff71358132db440b82747707b3c7c99efca6670 (diff) | |
download | binutils-576745e26c0ec76a53ba45b20af464628a50b3e4.zip binutils-576745e26c0ec76a53ba45b20af464628a50b3e4.tar.gz binutils-576745e26c0ec76a53ba45b20af464628a50b3e4.tar.bz2 |
Fix printing of global variable stubs if no inferior is running
Since 3c45e9f915ae4aeab7312d6fc55a947859057572 gdb crashes when trying
to print a global variable stub without a running inferior, because of
a missing nullptr-check (the block_scope function took care of that
check before it was converted to a method).
With this check it works again:
```
(gdb) print s
$1 = <incomplete type>
```
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31128
Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/cp-namespace.c')
-rw-r--r-- | gdb/cp-namespace.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index 975e789..1ec00dc 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -1027,7 +1027,11 @@ cp_lookup_transparent_type (const char *name) /* If that doesn't work and we're within a namespace, look there instead. */ - scope = get_selected_block (0)->scope (); + const block *block = get_selected_block (0); + if (block == nullptr) + return nullptr; + + scope = block->scope (); if (scope[0] == '\0') return NULL; |