diff --git a/collects/ffi/unsafe/alloc.rkt b/collects/ffi/unsafe/alloc.rkt index 5b03678069..107e910b62 100644 --- a/collects/ffi/unsafe/alloc.rkt +++ b/collects/ffi/unsafe/alloc.rkt @@ -23,8 +23,9 @@ start-atomic (lambda () (let ([v (apply proc args)]) - (hash-set! allocated v (list d)) - (register-finalizer v deallocate) + (when v + (hash-set! allocated v (list d)) + (register-finalizer v deallocate)) v)) end-atomic)) proc))