This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Don't reference past the end of the vector
- From: Tom Tromey <tromey at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 9 Feb 2018 13:46:26 -0000
- Subject: [binutils-gdb] Don't reference past the end of the vector
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9c3630e983df43e68006b526a92c2a9a2b64dfd9
commit 9c3630e983df43e68006b526a92c2a9a2b64dfd9
Author: Tom Tromey <tom@tromey.com>
Date: Fri Feb 9 05:58:46 2018 -0700
Don't reference past the end of the vector
An earlier change made find_source_lines read:
end = &data[size];
However, since 'size' is the size of the vector, this seems fishy.
More obviously ok is to compute the end of the data directly:
end = data.data () + size;
2018-02-09 Tom Tromey <tom@tromey.com>
* source.c (find_source_lines): Don't reference past the end of
the vector.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/source.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f1d662f..b554fce 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2018-02-09 Tom Tromey <tom@tromey.com>
+
+ * source.c (find_source_lines): Don't reference past the end of
+ the vector.
+
2018-02-09 Markus Metzger <markus.t.metzger@intel.com>
* remote.c (remote_btrace_maybe_reopen): Change error message.
diff --git a/gdb/source.c b/gdb/source.c
index 9eec58f..009bec5 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -1219,7 +1219,7 @@ find_source_lines (struct symtab *s, int desc)
size = myread (desc, data.data (), size);
if (size < 0)
perror_with_name (symtab_to_filename_for_display (s));
- end = &data[size];
+ end = data.data () + size;
p = &data[0];
line_charpos[0] = 0;
nlines = 1;