From 2851b2c55f54b651f250525528c57868e419baa1 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 12 Mar 2018 13:04:28 +0000 Subject: eval_error.c: fix underflow * eval_error.c (print_errinfo): get rid of negative string length. [ruby-core:86086] [Bug #14598] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- eval_error.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'eval_error.c') diff --git a/eval_error.c b/eval_error.c index 346b76ed5f..d909125fbd 100644 --- a/eval_error.c +++ b/eval_error.c @@ -129,15 +129,13 @@ print_errinfo(const VALUE eclass, const VALUE errat, const VALUE emesg, const VA } else { const char *tail = 0; - long len = elen; if (emesg == Qundef && highlight) write_warn(str, bold); if (RSTRING_PTR(epath)[0] == '#') epath = 0; if ((tail = memchr(einfo, '\n', elen)) != 0) { - len = tail - einfo; + write_warn2(str, einfo, tail - einfo); tail++; /* skip newline */ - write_warn2(str, einfo, len); } else { write_warn_str(str, emesg); @@ -159,7 +157,7 @@ print_errinfo(const VALUE eclass, const VALUE errat, const VALUE emesg, const VA if (einfo[elen-1] == '\n') --elen; write_warn(str, bold); } - write_warn2(str, tail, elen - len - 1); + if (tail < einfo+elen) write_warn2(str, tail, einfo+elen-tail); } if (tail ? (highlight || einfo[elen-1] != '\n') : !epath) { if (highlight) write_warn(str, reset); -- cgit v1.2.3