Skip to content

Commit

Permalink
Fix segmentation fault while passing data in mruby binding
Browse files Browse the repository at this point in the history
  • Loading branch information
pulsejet committed Apr 28, 2018
1 parent bf76b90 commit dffd705
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions binding-mruby/binding-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <mruby/data.h>
#include <mruby/variable.h>
#include <mruby/class.h>
#include <mruby/string.h>

#include <stdio.h>

Expand Down Expand Up @@ -352,11 +353,13 @@ inline mrb_value
objectLoad(mrb_state *mrb, mrb_value self, const mrb_data_type &type)
{
RClass *klass = mrb_class_ptr(self);
char *data;
int data_len;
mrb_get_args(mrb, "s", &data, &data_len);

C *c = C::deserialize(data, data_len);
mrb_value data;
mrb_get_args(mrb, "S", &data);

int data_len = mrb_string_value_len(mrb, data);

C *c = C::deserialize(RSTRING_PTR(data), data_len);

RData *obj = mrb_data_object_alloc(mrb, klass, c, &type);
mrb_value obj_value = mrb_obj_value(obj);
Expand Down

0 comments on commit dffd705

Please sign in to comment.