Skip to content

Commit

Permalink
Wait to complete the test before releasing the agile reference. (#112387
Browse files Browse the repository at this point in the history
)

Otherwise we can end up with a use-after-free
  • Loading branch information
jkoritzinsky authored Feb 11, 2025
1 parent b0ad53e commit 7e82ad9
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/tests/Interop/COM/ComWrappers/API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,7 @@ public unsafe void CrossApartmentQueryInterface_NoDeadlock()

staThread.Start();
mtaThread.Start();
testCompleted.WaitOne();
}
finally
{
Expand All @@ -1092,8 +1093,6 @@ public unsafe void CrossApartmentQueryInterface_NoDeadlock()
Marshal.Release(agileReference);
}
}

testCompleted.WaitOne();
}

[DllImport("ole32.dll")]
Expand Down

0 comments on commit 7e82ad9

Please sign in to comment.