mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
shareable: Bug fix: Double free
This commit is contained in:
parent
6687ffe8ba
commit
693116ffd6
@ -156,6 +156,9 @@ func (i *Image) forceShared() {
|
||||
newI.replacePixels(pixels)
|
||||
i.dispose(false)
|
||||
*i = *newI
|
||||
// TODO: This is a very tricky hack not to call Dispose twice for the same backend.
|
||||
// Avoid such hack.
|
||||
runtime.SetFinalizer(newI, nil)
|
||||
}
|
||||
|
||||
func (i *Image) region() (x, y, width, height int) {
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"errors"
|
||||
"image/color"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
@ -183,4 +184,6 @@ func TestReshared(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
runtime.GC()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user