From: Alexander Gavrilov Date: Sat, 23 Oct 2010 08:43:10 +0000 (+0400) Subject: Make handle slots unbound after deallocating C objects. X-Git-Tag: 0.2~11 X-Git-Url: https://repo.or.cz/w/cl-sqlite.git/commitdiff_plain/b3ca7573f76b7472078bc262ab74f3ccffd9e524 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. --- 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.