diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-25 10:31:58 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-25 10:31:58 +0000 |
commit | 26c3611480ec30128a95ff943b9403e4fb5aa7ea (patch) | |
tree | 43f870373d53a2d6c37807e1dab7a6c139b60d78 /ext | |
parent | 203831173c9e9f747e4311a9519840890e2bb655 (diff) | |
download | ruby-26c3611480ec30128a95ff943b9403e4fb5aa7ea.tar.gz ruby-26c3611480ec30128a95ff943b9403e4fb5aa7ea.tar.xz ruby-26c3611480ec30128a95ff943b9403e4fb5aa7ea.zip |
* ext/digest/digest.c (rb_digest_instance_method_unimpl): Do not
call rb_inspect() on an object that does not implement necessary
methods; reported by NaHi.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/digest/digest.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/ext/digest/digest.c b/ext/digest/digest.c index 48297082f..f723bbdbd 100644 --- a/ext/digest/digest.c +++ b/ext/digest/digest.c @@ -83,6 +83,15 @@ rb_digest_s_hexencode(VALUE klass, VALUE str) * object to calculate message digest values. */ +static void +rb_digest_instance_method_unimpl(VALUE self, const char *method) +{ + VALUE klass = rb_obj_class(self); + + rb_raise(rb_eRuntimeError, "%s does not implement %s()", + rb_obj_classname(self), method); +} + /* * call-seq: * digest_obj.update(string) -> digest_obj @@ -97,7 +106,7 @@ rb_digest_s_hexencode(VALUE klass, VALUE str) static VALUE rb_digest_instance_update(VALUE self, VALUE str) { - rb_raise(rb_eRuntimeError, "%s does not implement update()", RSTRING_PTR(rb_inspect(self))); + rb_digest_instance_method_unimpl(self, "update"); } /* @@ -115,7 +124,7 @@ rb_digest_instance_update(VALUE self, VALUE str) static VALUE rb_digest_instance_finish(VALUE self) { - rb_raise(rb_eRuntimeError, "%s does not implement finish()", RSTRING_PTR(rb_inspect(self))); + rb_digest_instance_method_unimpl(self, "finish"); } /* @@ -129,7 +138,7 @@ rb_digest_instance_finish(VALUE self) static VALUE rb_digest_instance_reset(VALUE self) { - rb_raise(rb_eRuntimeError, "%s does not implement reset()", RSTRING_PTR(rb_inspect(self))); + rb_digest_instance_method_unimpl(self, "reset"); } /* @@ -358,7 +367,7 @@ rb_digest_instance_length(VALUE self) static VALUE rb_digest_instance_block_length(VALUE self) { - rb_raise(rb_eRuntimeError, "%s does not implement block_length()", RSTRING_PTR(rb_inspect(self))); + rb_digest_instance_method_unimpl(self, "block_length"); } /* |