diff options
author | Chad Austin <chad@imvu.com> | 2013-12-06 19:49:02 -0800 |
---|---|---|
committer | Bruce Mitchener <bruce.mitchener@gmail.com> | 2014-02-04 16:22:17 +0700 |
commit | b5cf147e6ce7a8d3277342d87beec76290a578bf (patch) | |
tree | 5cbf709d9867fada96ef022f67b3f0f79171778a /tests | |
parent | 9ba56d2c20fb2a5d5572e6030bd9dc1794fefdd2 (diff) |
Fix a possible double-deletion in embind when returning a smart pointer from an abstract class implementation.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/embind/embind.test.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/embind/embind.test.js b/tests/embind/embind.test.js index a36c8b08..5ca972be 100644 --- a/tests/embind/embind.test.js +++ b/tests/embind/embind.test.js @@ -1591,7 +1591,7 @@ module({ test("returning a new shared pointer from interfaces implemented in JS code does not leak", function() { var impl = cm.AbstractClass.implement({ returnsSharedPtr: function() { - return cm.embind_test_return_smart_derived_ptr(); + return cm.embind_test_return_smart_derived_ptr().deleteLater(); } }); cm.callReturnsSharedPtrMethod(impl); @@ -1925,6 +1925,19 @@ module({ a.delete(); }); }); + + test("returning a cached new shared pointer from interfaces implemented in JS code does not leak", function() { + var derived = cm.embind_test_return_smart_derived_ptr(); + var impl = cm.AbstractClass.implement({ + returnsSharedPtr: function() { + return derived; + } + }); + cm.callReturnsSharedPtrMethod(impl); + impl.delete(); + derived.delete(); + // Let the memory leak test superfixture check that no leaks occurred. + }); }); /* global run_all_tests */ |