diff options
author | Alan Modra <amodra@gmail.com> | 2022-10-26 09:41:55 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-10-26 15:34:53 +1030 |
commit | 6175be41757e886ce8ef5e792834aced3f5ae397 (patch) | |
tree | 966586c6e434728413c6453d7470680eda79c30c /binutils | |
parent | 9254cd1fd8682d4a51dc1b13cf8067473d3041ea (diff) | |
download | gdb-6175be41757e886ce8ef5e792834aced3f5ae397.zip gdb-6175be41757e886ce8ef5e792834aced3f5ae397.tar.gz gdb-6175be41757e886ce8ef5e792834aced3f5ae397.tar.bz2 |
PR29720, objdump -S crashes if build-id is missing
PR 29720
* objdump.c (slurp_file): Don't call debuginfod_find_source
when build_id is NULL.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/objdump.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/binutils/objdump.c b/binutils/objdump.c index f7b4695..a4ab0db 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -1879,17 +1879,19 @@ slurp_file (const char * fn, #if HAVE_LIBDEBUGINFOD if (fd < 0 && use_debuginfod && fn[0] == '/' && abfd != NULL) { - unsigned char * build_id; - debuginfod_client * client; + unsigned char *build_id = get_build_id (abfd); - client = debuginfod_begin (); - if (client == NULL) - return NULL; + if (build_id) + { + debuginfod_client *client = debuginfod_begin (); - build_id = get_build_id (abfd); - fd = debuginfod_find_source (client, build_id, 0, fn, NULL); - free (build_id); - debuginfod_end (client); + if (client) + { + fd = debuginfod_find_source (client, build_id, 0, fn, NULL); + debuginfod_end (client); + } + free (build_id); + } } #endif |