Skip to content

Commit 4dffc5f

Browse files
committed
fix bug in that we must initialize pointer before registering cleanup
1 parent 4092f36 commit 4dffc5f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

SwiftKitFFM/src/main/java/org/swift/swiftkit/ffm/FFMSwiftInstance.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ public abstract class FFMSwiftInstance extends SwiftInstance {
2929
* @param arena the arena this object belongs to. When the arena goes out of scope, this value is destroyed.
3030
*/
3131
protected FFMSwiftInstance(MemorySegment segment, AllocatingSwiftArena arena) {
32-
super(arena);
3332
this.memorySegment = segment;
33+
34+
// Only register once we have fully initialized the object since this will need the object pointer.
35+
arena.register(this);
3436
}
3537

3638
/**

0 commit comments

Comments
 (0)