aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/source.c1
2 files changed, 5 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b274364..a7ee02c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2021-05-17 Tom Tromey <tromey@adacore.com>
+ * source.c (add_path): Check 'p' before using 'p[-1]'.
+
+2021-05-17 Tom Tromey <tromey@adacore.com>
+
* dwarf2/read.h (struct dwarf2_per_cu_data_deleter: New.
(dwarf2_per_cu_data_up): New typedef.
(struct dwarf2_per_bfd) <allocate_per_cu>: Change return type.
diff --git a/gdb/source.c b/gdb/source.c
index 6fc27ae..b6dab6e 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -537,6 +537,7 @@ add_path (const char *dirname, char **which_path, int parse_separators)
/* On MS-DOS and MS-Windows, h:\ is different from h: */
&& !(p == name + 3 && name[1] == ':') /* "d:/" */
#endif
+ && p > name
&& IS_DIR_SEPARATOR (p[-1]))
/* Sigh. "foo/" => "foo" */
--p;