From b3ca7573f76b7472078bc262ab74f3ccffd9e524 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sat, 23 Oct 2010 12:43:10 +0400 Subject: [PATCH] Make handle slots unbound after deallocating C objects. This would ensure an immediate failure at lisp level if they are accessed later by mistake, instead of a segfault. --- sqlite.lisp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sqlite.lisp b/sqlite.lisp index 482cbea..1a4f755 100644 --- a/sqlite.lisp +++ b/sqlite.lisp @@ -64,7 +64,8 @@ (really-finalize-statement statement)) (let ((error-code (sqlite-ffi:sqlite3-close (handle handle)))) (unless (eq error-code :ok) - (error "Received error code ~A when trying to close ~A (connected to ~A)" error-code handle (database-path handle))))) + (error "Received error code ~A when trying to close ~A (connected to ~A)" error-code handle (database-path handle))) + (slot-makunbound handle 'handle))) (defclass sqlite-statement () ((db :reader db :initarg :db) @@ -114,7 +115,8 @@ Example: (defun really-finalize-statement (statement) (setf (sqlite-handle-statements (db statement)) (delete statement (sqlite-handle-statements (db statement)))) - (sqlite-ffi:sqlite3-finalize (handle statement))) + (sqlite-ffi:sqlite3-finalize (handle statement)) + (slot-makunbound statement 'handle)) (defun finalize-statement (statement) "Finalizes the statement and signals that associated resources may be released. -- 2.11.4.GIT