Skip to content

Commit d23d925

Browse files
hsbtclaude
andcommitted
Return the full input length from Zlib::ZStream#avail_in
The int cast turned a remainder longer than INT_MAX into a wrong or negative number. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent d698ea0 commit d23d925

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎ext/zlib/zlib.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
typedef long rb_len_t;
1717
typedef unsigned long rb_ulen_t;
1818
# define SIZEOF_RB_LEN_T SIZEOF_LONG
19+
# define LEN2NUM LONG2NUM
1920
# define NUM2LEN NUM2LONG
2021
# define PRIdLEN "ld"
2122
#endif
@@ -1536,7 +1537,7 @@ rb_zstream_avail_in(VALUE obj)
15361537
{
15371538
struct zstream *z;
15381539
TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z);
1539-
return INT2FIX(NIL_P(z->input) ? 0 : (int)(RSTRING_LEN(z->input)));
1540+
return NIL_P(z->input) ? INT2FIX(0) : LEN2NUM(RSTRING_LEN(z->input));
15401541
}
15411542

15421543
/*

0 commit comments

Comments
 (0)