]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/62059 (signed integer overflow in diagnostic.c adjust_line)
authorMarek Polacek <polacek@redhat.com>
Sun, 17 Aug 2014 16:19:43 +0000 (16:19 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Sun, 17 Aug 2014 16:19:43 +0000 (16:19 +0000)
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

gcc/ChangeLog
gcc/diagnostic.c

index 98c59d4c7153a1e89a7cdfa77977f39268db268b..0850165611c8be7746f7b3c8ba922fc9a34e1875 100644 (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
index b457e5aa2d9d8bfe36f430e33890659931b1ace7..2226821bc4934817f24fc51a91095bf294693acc 100644 (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;