summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNARUSE, Yui <naruse@airemix.jp>2023-01-19 11:05:29 +0900
committerNARUSE, Yui <naruse@airemix.jp>2023-01-19 11:05:29 +0900
commit1a2447ac9925e7794a7c5aa07960ad4de08e6aca (patch)
tree4300d2dc5d1b982193ccf7abc33d2dd781b97dc9
parent08ae7f64dc52c2b61e451d6e79ebdae73d482677 (diff)
downloadruby-1a2447ac9925e7794a7c5aa07960ad4de08e6aca.tar.gz
merge revision(s) 979dd02e2f0a70f3f30d47c6115780d8fac6147e: [Backport #19262]
Check if the argument is Thread::Backtrace::Location object [Bug #19262] --- ast.c | 5 +++++ test/ruby/test_ast.rb | 6 ++++++ 2 files changed, 11 insertions(+)
-rw-r--r--ast.c5
-rw-r--r--test/ruby/test_ast.rb6
-rw-r--r--version.h2
3 files changed, 12 insertions, 1 deletions
diff --git a/ast.c b/ast.c
index bf3781d820..adb7287ed3 100644
--- a/ast.c
+++ b/ast.c
@@ -202,6 +202,11 @@ static VALUE
node_id_for_backtrace_location(rb_execution_context_t *ec, VALUE module, VALUE location)
{
int node_id;
+
+ if (!rb_frame_info_p(location)) {
+ rb_raise(rb_eTypeError, "Thread::Backtrace::Location object expected");
+ }
+
node_id = rb_get_node_id_from_frame_info(location);
if (node_id == -1) {
return Qnil;
diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb
index 8acf4fe254..e43dac28b3 100644
--- a/test/ruby/test_ast.rb
+++ b/test/ruby/test_ast.rb
@@ -227,6 +227,12 @@ class TestAst < Test::Unit::TestCase
assert_equal node.node_id, node_id
end
+ def test_node_id_for_backtrace_location_raises_argument_error
+ bug19262 = '[ruby-core:111435]'
+
+ assert_raise(TypeError, bug19262) { RubyVM::AbstractSyntaxTree.node_id_for_backtrace_location(1) }
+ end
+
def test_of_proc_and_method
proc = Proc.new { 1 + 2 }
method = self.method(__method__)
diff --git a/version.h b/version.h
index e207d9b5b2..e334ced0da 100644
--- a/version.h
+++ b/version.h
@@ -11,7 +11,7 @@
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 12
+#define RUBY_PATCHLEVEL 13
#include "ruby/version.h"
#include "ruby/internal/abi.h"