Commit 0a8923fa by Martin Sebor Committed by Martin Sebor

PR c++/81586 - valgrind error in output_buffer_append_r with -Wall

gcc/ChangeLog:

	PR c++/81586
	* pretty-print.c (pp_format): Correct the handling of %s precision.

From-SVN: r251029
parent 8e941ae9
2017-08-10 Martin Sebor <msebor@redhat.com>
PR c++/81586
* pretty-print.c (pp_format): Correct the handling of %s precision.
2017-08-10 H.J. Lu <hongjiu.lu@intel.com>
PR target/81736
......
......@@ -667,7 +667,17 @@ pp_format (pretty_printer *pp, text_info *text)
}
s = va_arg (*text->args_ptr, const char *);
pp_append_text (pp, s, s + n);
/* Negative precision is treated as if it were omitted. */
if (n < 0)
n = INT_MAX;
/* Append the lesser of precision and strlen (s) characters. */
size_t len = strlen (s);
if ((unsigned) n < len)
len = n;
pp_append_text (pp, s, s + len);
}
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment