diff --git a/ext/digest/bubblebabble/bubblebabble.c b/ext/digest/bubblebabble/bubblebabble.c index dac603c..26c6081 100644 --- a/ext/digest/bubblebabble/bubblebabble.c +++ b/ext/digest/bubblebabble/bubblebabble.c @@ -14,6 +14,10 @@ #include #include "../digest.h" +#ifndef HAVE_RB_LEN_T +# define RB_LEN_MAX LONG_MAX +#endif + static ID id_digest; static VALUE @@ -36,7 +40,7 @@ bubblebabble_str_new(VALUE str_digest) digest = RSTRING_PTR(str_digest); digest_len = RSTRING_LEN(str_digest); - if ((LONG_MAX - 2) / 3 < (digest_len | 1)) { + if ((RB_LEN_MAX - 2) / 3 < (digest_len | 1)) { rb_raise(rb_eRuntimeError, "digest string too long"); } diff --git a/ext/digest/digest.c b/ext/digest/digest.c index c3feab1..9ae244f 100644 --- a/ext/digest/digest.c +++ b/ext/digest/digest.c @@ -17,6 +17,7 @@ #include "digest.h" #ifndef HAVE_RB_LEN_T +# define RB_LEN_MAX LONG_MAX # define LEN2NUM LONG2NUM #endif @@ -116,7 +117,7 @@ hexencode_str_new(VALUE str_digest) digest = RSTRING_PTR(str_digest); digest_len = RSTRING_LEN(str_digest); - if (LONG_MAX / 2 < digest_len) { + if (RB_LEN_MAX / 2 < digest_len) { rb_raise(rb_eRuntimeError, "digest string too long"); }