Fix segmentation fault while passing data in mruby binding

This commit is contained in:
Varun Patil 2018-04-28 14:40:59 +05:30
parent 39ac6aecf0
commit 8b216995cc
1 changed files with 7 additions and 4 deletions

View File

@ -28,6 +28,7 @@
#include <mruby/data.h>
#include <mruby/variable.h>
#include <mruby/class.h>
#include <mruby/string.h>
#include <stdio.h>
@ -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);