зеркало из https://github.com/github/ruby.git
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
This commit is contained in:
Родитель
7773cfa496
Коммит
2851b2c55f
|
@ -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);
|
||||
|
|
|
@ -1254,5 +1254,13 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
|
|||
|
||||
_, err2, status1 = EnvUtil.invoke_ruby(['-e', "#{test_method}; begin; foo; end"], '', true, true)
|
||||
assert_equal(err2, out1)
|
||||
|
||||
if $stderr.tty?
|
||||
e = RuntimeError.new("a\n")
|
||||
message = assert_nothing_raised(ArgumentError, proc {e.pretty_inspect}) do
|
||||
e.full_message
|
||||
end
|
||||
assert_operator(message, :end_with?, "\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче