mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +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