Skip to content

Commit c5d862f

Browse files
authored
Merge pull request #336 from Shopify/check-ext-code-fixnum
Packer_write_extension: handle T_BIGNUM
2 parents 1bad12b + 34a7400 commit c5d862f

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

ext/msgpack/packer_class.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,12 @@ static VALUE Packer_write_extension(VALUE self, VALUE obj)
233233
msgpack_packer_t *pk = MessagePack_Packer_get(self);
234234
Check_Type(obj, T_STRUCT);
235235

236-
int ext_type = FIX2INT(RSTRUCT_GET(obj, 0));
236+
VALUE rb_ext_type = RSTRUCT_GET(obj, 0);
237+
if(!RB_TYPE_P(rb_ext_type, T_FIXNUM)) {
238+
rb_raise(rb_eRangeError, "integer %s too big to convert to `signed char'", RSTRING_PTR(rb_String(rb_ext_type)));
239+
}
240+
241+
int ext_type = FIX2INT(rb_ext_type);
237242
if(ext_type < -128 || ext_type > 127) {
238243
rb_raise(rb_eRangeError, "integer %d too big to convert to `signed char'", ext_type);
239244
}

0 commit comments

Comments
 (0)