1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Check metadata a bit more

This commit is contained in:
Nobuyoshi Nakada 2019-08-23 13:00:17 +09:00
parent 650cd24555
commit a5b809e994
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -554,10 +554,22 @@ get_digest_base_metadata(VALUE klass)
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;