re PR c/62059 (signed integer overflow in diagnostic.c adjust_line)

PR c/62059
	* diagnostic.c (adjust_line): Add gcc_checking_assert.
	(diagnostic_show_locus): Don't print caret diagnostic
	if a column is larger than the line_width.

Co-Authored-By: Manuel López-Ibáñez <manu@gcc.gnu.org>

From-SVN: r214074
This commit is contained in:
Marek Polacek 2014-08-17 16:19:43 +00:00 committed by Marek Polacek
parent 387d13bc7b
commit 544c27ba10
2 changed files with 10 additions and 1 deletions

View File

@ -1,3 +1,11 @@
2014-08-17 Marek Polacek <polacek@redhat.com>
Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/62059
* diagnostic.c (adjust_line): Add gcc_checking_assert.
(diagnostic_show_locus): Don't print caret diagnostic
if a column is larger than the line_width.
2014-08-17 Roman Gareev <gareevroman@gmail.com>
* common.opt: Make the ISL AST generator to be the main code generator

View File

@ -268,6 +268,7 @@ adjust_line (const char *line, int line_width,
int right_margin = 10;
int column = *column_p;
gcc_checking_assert (line_width >= column);
right_margin = MIN (line_width - column, right_margin);
right_margin = max_width - right_margin;
if (line_width >= max_width && column > right_margin)
@ -300,7 +301,7 @@ diagnostic_show_locus (diagnostic_context * context,
context->last_location = diagnostic->location;
s = expand_location_to_spelling_point (diagnostic->location);
line = location_get_source_line (s, &line_width);
if (line == NULL)
if (line == NULL || s.column > line_width)
return;
max_width = context->caret_max_width;