From 0d6d285423b21170aa323cb7df8f41c54023b448 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Wed, 24 Nov 2010 07:08:54 -0700 Subject: [PATCH] clear objc ivar on `dealloc' so that a field is not incorrectly used if the super `dealloc' triggers callbacks --- collects/ffi/unsafe/objc.rkt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/collects/ffi/unsafe/objc.rkt b/collects/ffi/unsafe/objc.rkt index a371abc34c..1166f80248 100644 --- a/collects/ffi/unsafe/objc.rkt +++ b/collects/ffi/unsafe/objc.rkt @@ -372,7 +372,9 @@ (define (free-fields obj names) (for-each (lambda (name) (let-values ([(ivar p) (object_getInstanceVariable obj name)]) - (when p (free-immobile-cell p)))) + (when p + (object_setInstanceVariable obj name #f) + (free-immobile-cell p)))) names)) ;; ----------------------------------------