Skip to content

Commit

Permalink
Merge pull request #176 from yast/fix_passing_ref
Browse files Browse the repository at this point in the history
Fix passing ref
  • Loading branch information
jreidinger committed Oct 26, 2016
2 parents 46e5309 + dcaf921 commit cf0dce3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
6 changes: 6 additions & 0 deletions package/yast2-ruby-bindings.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Oct 26 09:46:54 UTC 2016 - jreidinger@suse.com

- fix crash when references passed between clients (bsc#935385)
- 3.2.1

-------------------------------------------------------------------
Thu Oct 13 08:55:07 UTC 2016 - jreidinger@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-ruby-bindings.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-ruby-bindings
Version: 3.2.0
Version: 3.2.1
Url: https://github.com/yast/yast-ruby-bindings
Release: 0
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
13 changes: 12 additions & 1 deletion src/binary/Y2YCPTypeConv.cc
Expand Up @@ -82,6 +82,13 @@ ycp_term_to_rb_term( YCPTerm ycpterm )
return rb_class_new_instance(RARRAY_LEN(params), RARRAY_PTR(params),cls);
}

extern "C" void
rb_ref_free(void *p)
{
SymbolEntry *ref = (SymbolEntry*) p;
delete ref;
}

extern "C" VALUE
ycp_ref_to_rb_ref( YCPReference ycpref )
{
Expand All @@ -93,7 +100,11 @@ ycp_ref_to_rb_ref( YCPReference ycpref )

VALUE yast = rb_define_module("Yast");
VALUE cls = rb_const_get(yast, rb_intern("YReference"));
return Data_Wrap_Struct(cls, 0, NULL, (void*)&*ycpref->entry());
SymbolEntryPtr se = ycpref->entry();
// create copy of SE to prevent deallocation as we do not store it in smart pointer in ruby,
// so create new copy see bsc#935385
SymbolEntry *sec = new SymbolEntry(se->nameSpace(), se->position(), se->name(), se->category(), se->type());
return Data_Wrap_Struct(cls, 0, rb_ref_free, (void*)sec);
}

extern "C" void
Expand Down

0 comments on commit cf0dce3

Please sign in to comment.