Fixed the double-free in the "deinit" method of the Sound Effect type in the Playdate bindings target and cover ownership.

This commit is contained in:
2026-07-26 00:45:45 +02:00
parent d233cbaddb
commit d84113f7a8
3 changed files with 251 additions and 3 deletions
@@ -38,10 +38,16 @@ extension Sound {
}
deinit {
if isOwned {
effectAPI.pointee.freeEffect.unsafelyUnwrapped(pointer)
// Subclasses free the C object in their own deinit with the
// subsystem's type-specific free (freeDelayLine, freeOverdrive,
// ...); freeing here as well would double-free. The base class
// owns only the custom-processor effects it creates itself.
if let processorBox {
if isOwned {
effectAPI.pointee.freeEffect.unsafelyUnwrapped(pointer)
}
processorBox.release()
}
processorBox?.release()
}
/// The wet/dry mix: 1 is fully processed, 0 fully dry.