Open
Description
The native method receives the same object, not a copy and the destructor ends up being called twice on the same object. The windows 32 bit target does copy the object by value *obj
if its small enough but with a similar outcome since it doesn't call the copy constructor so it may end up trying to free an internal buffer twice.
public void TestObjectPassByValue1451()
{
using (var s = new Issue1451())
{
s.A = 500;
Assert.IsTrue(CSharp.CSharp.TestObjectPassByValue(s));
Assert.That(s.A, Is.EqualTo(500));
}
}
struct DLL_API Issue1451 {
int a;
int* b;
static bool success;
Issue1451();
};
Issue1451::Issue1451()
{
a = 0;
b = nullptr;
}
bool TestObjectPassByValue(Issue1451 s)
{
s.a = 99999;
return true;
}