ruby-changes:57226
From: Nobuyoshi <ko1@a...>
Date: Fri, 23 Aug 2019 13:03:17 +0900 (JST)
Subject: [ruby-changes:57226] Nobuyoshi Nakada: a5b809e994 (master): Check metadata a bit more
https://git.ruby-lang.org/ruby.git/commit/?id=a5b809e994 From a5b809e994ce10d265e73f8c9d7c042e5e84d171 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 23 Aug 2019 13:00:17 +0900 Subject: Check metadata a bit more diff --git a/ext/digest/digest.c b/ext/digest/digest.c index 73655c5..a59f880 100644 --- a/ext/digest/digest.c +++ b/ext/digest/digest.c @@ -554,10 +554,22 @@ get_digest_base_metadata(VALUE klass) https://github.com/ruby/ruby/blob/trunk/ext/digest/digest.c#L554 if (NIL_P(p)) rb_raise(rb_eRuntimeError, "Digest::Base cannot be directly inherited in Ruby"); + if (!RB_TYPE_P(obj, T_DATA) || RTYPEDDATA_P(obj)) { + wrong: + if (p == klass) + rb_raise(rb_eTypeError, "%"PRIsVALUE"::metadata is not initialized properly", + klass); + else + rb_raise(rb_eTypeError, "%"PRIsVALUE"(%"PRIsVALUE")::metadata is not initialized properly", + klass, p); + } + #undef RUBY_UNTYPED_DATA_WARNING #define RUBY_UNTYPED_DATA_WARNING 0 Data_Get_Struct(obj, rb_digest_metadata_t, algo); + if (!algo) goto wrong; + switch (algo->api_version) { case 3: break; -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/