diff options
author | Marek Polacek <polacek@redhat.com> | 2014-08-17 16:19:43 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2014-08-17 16:19:43 +0000 |
commit | 544c27ba1068e93b93baa526115543384aa19e12 (patch) | |
tree | 2773d0cf8462e6983fa4c00168beb33c14fc177e /gcc/diagnostic.c | |
parent | 387d13bc7bc2d8b60e33a486ede838e8b57957c4 (diff) | |
download | gcc-544c27ba1068e93b93baa526115543384aa19e12.tar.gz |
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
Diffstat (limited to 'gcc/diagnostic.c')
-rw-r--r-- | gcc/diagnostic.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index b457e5aa2d9..2226821bc49 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -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; |