receiver variables must be "mrb_int" for mrb_get_args("i").
Otherwise, it can cause a segfault on the platforms where the
size of "int" and "mrb_int" differs.
MODIFY
src/socket.c
src/socket.c
@@ -586,10 +586,10 @@ static mrb_value
mrb_socket_bind(mrb_state *mrb, mrb_value klass)
{
mrb_value sastr;
- int s;
+ mrb_int s;
mrb_get_args(mrb, "iS", &s, &sastr);
- if (bind(s, (struct sockaddr *)RSTRING_PTR(sastr), (socklen_t)RSTRING_LEN(sastr)) == -1) {
+ if (bind((int)s, (struct sockaddr *)RSTRING_PTR(sastr), (socklen_t)RSTRING_LEN(sastr)) == -1) {
mrb_sys_fail(mrb, "bind");
}
return mrb_nil_value();
@@ -599,10 +599,10 @@ static mrb_value
mrb_socket_connect(mrb_state *mrb, mrb_value klass)
{
mrb_value sastr;
- int s;
+ mrb_int s;
mrb_get_args(mrb, "iS", &s, &sastr);
- if (connect(s, (struct sockaddr *)RSTRING_PTR(sastr), (socklen_t)RSTRING_LEN(sastr)) == -1) {
+ if (connect((int)s, (struct sockaddr *)RSTRING_PTR(sastr), (socklen_t)RSTRING_LEN(sastr)) == -1) {
mrb_sys_fail(mrb, "connect");
}
return mrb_nil_value();

receiver variables must be "mrb_int" for mrb_get_args("i").

Otherwise, it can cause a segfault on the platforms where the
size of "int" and "mrb_int" differs.