aboutsummaryrefslogtreecommitdiffstats
path: root/eval_error.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-12 13:04:28 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-12 13:04:28 +0000
commitb8c712fa2c3145b3e0114e562d6184d41bfb6f2a (patch)
tree6b28f45baa795ef77582275388113ab22766f792 /eval_error.c
parent1e2fdba5e3068b4f3396dafe4359d16695656da1 (diff)
downloadruby-b8c712fa2c3145b3e0114e562d6184d41bfb6f2a.tar.gz
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
Diffstat (limited to 'eval_error.c')
-rw-r--r--eval_error.c6
1 files changed, 2 insertions, 4 deletions
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);