diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 397a08f20b5..22a473a4037 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2019-06-17 Tom de Vries + + PR gdb/24617 + * common/pathstuff.c (child_path): Make sure parent_len > 0 before + accessing parent[parent_len - 1]. + 2019-06-17 Paul Pluzhnikov PR gdb/24364 diff --git a/gdb/common/pathstuff.c b/gdb/common/pathstuff.c index e0e048d6654..b295e73237b 100644 --- a/gdb/common/pathstuff.c +++ b/gdb/common/pathstuff.c @@ -158,7 +158,7 @@ child_path (const char *parent, const char *child) /* The parent path must be a directory and the child must contain at least one component underneath the parent. */ const char *child_component; - if (IS_DIR_SEPARATOR (parent[parent_len - 1])) + if (parent_len > 0 && IS_DIR_SEPARATOR (parent[parent_len - 1])) { /* The parent path ends in a directory separator, so it is a directory. The first child component starts after the common