From 31cd0253d521f458da739ac0b3c545a32bfadf03 Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Mon, 11 Feb 2008 18:36:17 +0100 Subject: Fix a bug that could cause FOREIGN-FREE to be called on a null pointer. darcs-hash:3821d2debba27096f9fd8dcb630aace179ba4e9b --- Lisp/libobjcl.lisp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Lisp/libobjcl.lisp b/Lisp/libobjcl.lisp index fda484c..6e8e2f5 100644 --- a/Lisp/libobjcl.lisp +++ b/Lisp/libobjcl.lisp @@ -826,11 +826,12 @@ separating parts by hyphens works nicely in all of the `:INVERT`, (let ((array-pointer (%objcl-class-direct-slots class-ptr count-ptr element-size-ptr))) - (unwind-protect - (loop with element-size = (mem-ref element-size-ptr :unsigned-int) - with count = (mem-ref count-ptr :unsigned-int) - for i from 0 below count - for current-slot = array-pointer - then (inc-pointer current-slot element-size) - collecting (mem-ref current-slot :pointer)) - (foreign-free array-pointer))))) + (unless (null-pointer-p array-pointer) + (unwind-protect + (loop with element-size = (mem-ref element-size-ptr :unsigned-int) + with count = (mem-ref count-ptr :unsigned-int) + for i from 0 below count + for current-slot = array-pointer + then (inc-pointer current-slot element-size) + collecting (mem-ref current-slot :pointer)) + (foreign-free array-pointer)))))) -- cgit v1.2.3