[RFA,7/9] Use std::vector in find_source_lines
Commit Message
>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
Tom> + end = &data[size];
Andre pointed out that this is possibly fishy, so I think perhaps the
appended should go in. Ok?
Tom
commit 4e40d3c76f0e14aea171c9ef7447c78defee8a74
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.
Comments
On 02/09/2018 01:00 PM, Tom Tromey wrote:
>>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:
>
> Tom> + end = &data[size];
>
> Andre pointed out that this is possibly fishy, so I think perhaps the
> appended should go in. Ok?
OK.
Thanks,
Pedro Alves
@@ -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 Joel Brobecker <brobecker@adacore.com>
* NEWS <Changes in GDB 8.1>: Clarify that "rbreak" is a new
@@ -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;