diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-31 13:01:55 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-31 13:01:55 +0000 |
commit | fa2e4a2061e140ce980bd2c8faef0d63bb408100 (patch) | |
tree | 07ad6a1e2089d846866e9ae5d1f71c16bc3f4be6 /error.c | |
parent | d0afbff3b047755f6a74446185cf08b5618387a0 (diff) |
error.c: negative uplevel
* error.c (rb_warn_m): negative uplevel is not allowed.
[ruby-core:84568] [Bug #14262]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r-- | error.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -342,7 +342,11 @@ rb_warn_m(int argc, VALUE *argv, VALUE exc) uplevel = Qnil; } else if (!NIL_P(uplevel)) { - uplevel = LONG2NUM((long)NUM2ULONG(uplevel) + 1); + long lev = NUM2LONG(uplevel); + if (lev < 0) { + rb_raise(rb_eArgError, "negative level (%ld)", lev); + } + uplevel = LONG2NUM(lev + 1); uplevel = rb_vm_thread_backtrace_locations(1, &uplevel, GET_THREAD()->self); if (!NIL_P(uplevel)) { uplevel = rb_ary_entry(uplevel, 0); |