From c0f505fecd35b6bc107c3a6330531a0201b126bb Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sat, 10 Oct 2026 03:56:10 +0900 Subject: [PATCH] Use LEN2NUM for Digest::Instance#digest_length RSTRING_LEN returns rb_len_t, which LONG2NUM would truncate where rb_len_t is wider than long. The fallback keeps older Ruby building. https://bugs.ruby-lang.org/issues/22400 Co-Authored-By: Claude Opus 5.5 --- ext/digest/digest.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ext/digest/digest.c b/ext/digest/digest.c index f0f0910..c3feab1 100644 --- a/ext/digest/digest.c +++ b/ext/digest/digest.c @@ -16,6 +16,10 @@ #define RB_DIGEST_WRAP_METADATA_LINKAGE RUBY_FUNC_EXPORTED #include "digest.h" +#ifndef HAVE_RB_LEN_T +# define LEN2NUM LONG2NUM +#endif + static VALUE rb_mDigest; static VALUE rb_mDigest_Instance; static VALUE rb_cDigest_Class; @@ -407,7 +411,7 @@ rb_digest_instance_digest_length(VALUE self) /* never blindly assume that #digest() returns a string */ StringValue(digest); - return LONG2NUM(RSTRING_LEN(digest)); + return LEN2NUM(RSTRING_LEN(digest)); } /*