Skip to content

Commit

Permalink
Support nil parameter when using adopt policy (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
vilarion authored May 15, 2020
1 parent 7555d9c commit 2fb1f5e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion luabind/adopt_policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ namespace luabind { namespace detail

object_rep* obj = static_cast<object_rep*>(
lua_touserdata(L, index));
obj->release();

if (obj)
{
obj->release();
}

adjust_backref_ownership(ptr, boost::is_polymorphic<T>());

Expand Down
6 changes: 6 additions & 0 deletions test/test_adopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,10 @@ void test_main(lua_State* L)
);

TEST_CHECK(Base::count == 0);

DOSTRING(L,
"take_ownership(nil)\n"
);

TEST_CHECK(adopted == 0);
}

0 comments on commit 2fb1f5e

Please sign in to comment.