+2017-03-24 Pádraig Brady <pbrady@fb.com>
+
+ * dwarf2read.c (setup_type_unit_groups): Ensure dir_index doesn't
+ reference beyond the 'lh->include_dirs' array before accessing to
+ it.
+ (psymtab_include_file_name): Likewise.
+ (dwarf_decode_lines_1): Likewise.
+ (dwarf_decode_lines): Likewise.
+ (file_file_name): Likewise.
+
2017-03-23 Simon Marchi <simon.marchi@ericsson.com>
* fbsd-tdep.c (fbsd_corefile_thread): Don't set/restore
const char *dir = NULL;
struct file_entry *fe = &lh->file_names[i];
- if (fe->dir_index && lh->include_dirs != NULL)
+ if (fe->dir_index && lh->include_dirs != NULL
+ && (fe->dir_index - 1) < lh->num_include_dirs)
dir = lh->include_dirs[fe->dir_index - 1];
dwarf2_start_subfile (fe->name, dir);
char *copied_name = NULL;
int file_is_pst;
- if (fe.dir_index && lh->include_dirs != NULL)
+ if (fe.dir_index && lh->include_dirs != NULL
+ && (fe.dir_index - 1) < lh->num_include_dirs)
dir_name = lh->include_dirs[fe.dir_index - 1];
if (!IS_ABSOLUTE_PATH (include_name)
struct file_entry *fe = &lh->file_names[state_machine.file - 1];
const char *dir = NULL;
- if (fe->dir_index && lh->include_dirs != NULL)
+ if (fe->dir_index && lh->include_dirs != NULL
+ && (fe->dir_index - 1) < lh->num_include_dirs)
dir = lh->include_dirs[fe->dir_index - 1];
dwarf2_start_subfile (fe->name, dir);
else
{
fe = &lh->file_names[state_machine.file - 1];
- if (fe->dir_index && lh->include_dirs != NULL)
+ if (fe->dir_index && lh->include_dirs != NULL
+ && (fe->dir_index - 1) < lh->num_include_dirs)
dir = lh->include_dirs[fe->dir_index - 1];
if (record_lines_p)
{
struct file_entry *fe;
fe = &lh->file_names[i];
- if (fe->dir_index && lh->include_dirs != NULL)
+ if (fe->dir_index && lh->include_dirs != NULL
+ && (fe->dir_index - 1) < lh->num_include_dirs)
dir = lh->include_dirs[fe->dir_index - 1];
dwarf2_start_subfile (fe->name, dir);
struct file_entry *fe = &lh->file_names[file - 1];
if (IS_ABSOLUTE_PATH (fe->name) || fe->dir_index == 0
- || lh->include_dirs == NULL)
+ || lh->include_dirs == NULL
+ || (fe->dir_index - 1) >= lh->num_include_dirs)
return xstrdup (fe->name);
return concat (lh->include_dirs[fe->dir_index - 1], SLASH_STRING,
fe->name, (char *) NULL);