From bb3a4efe13c0bd9a7b15ecd02ddb966870a03bd0 Mon Sep 17 00:00:00 2001 From: Lancelot SIX Date: Thu, 25 Feb 2021 00:30:49 +0000 Subject: [PR gdb/27393] set directories: handle empty dirs. As reported in gdb/27393, the 'directory' and 'set directories' commands fail when parsing an empty dir name: (gdb) set directories "" /home/lsix/dev/gnu/binutils-gdb/gdbsupport/pathstuff.cc:132: internal-error: gdb::unique_xmalloc_ptr gdb_abspath(const char*): Assertion `path != NULL && path[0] != '\0'' failed. or (gdb) dir : /home/lsix/dev/gnu/binutils-gdb/gdbsupport/pathstuff.cc:132: internal-error: gdb::unique_xmalloc_ptr gdb_abspath(const char*): Assertion `path != NULL && path[0] != '\0'' failed. This patch fixes this issue by ignoring any attempt to add an empty name to the source directories list. 'set dir ""' will reset the directories list the same way 'set dir' would do it. Tested on x86_64. --- gdb/source.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gdb/source.c') diff --git a/gdb/source.c b/gdb/source.c index dc30dac..3a8f829 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -572,6 +572,8 @@ add_path (const char *dirname, char **which_path, int parse_separators) break; } + if (name[0] == '\0') + goto skip_dup; if (name[0] == '~') new_name_holder.reset (tilde_expand (name)); #ifdef HAVE_DOS_BASED_FILE_SYSTEM -- cgit v1.1