fix bug #65936 (dangling context pointer causes crash)

reported by Leon Sorokin