From 4851184503a36e0e0807ddd9e01e7b7698608560 Mon Sep 17 00:00:00 2001
From: wlott <wlott>
Date: Sun, 29 Jul 1990 07:02:31 +0000
Subject: [PATCH] Changed compute-call-form to check pointer return values for
 NULL.  If the returned pointer is NULL, return NIL instead of an alien.

---
 code/c-call.lisp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/code/c-call.lisp b/code/c-call.lisp
index 1f97a213f..50cf85ab6 100644
--- a/code/c-call.lisp
+++ b/code/c-call.lisp
@@ -528,9 +528,12 @@
 	 (unless (c-type-size type)
 	   (error "Can't return pointers to objects of unknown size: ~S"
 		  (c-type-description return-type)))
-	 `(make-alien ',(c-type-description type)
-		      ,(c-type-size type)
-		      ,(sub-compute-call-form 'system-area-pointer))))
+	 (let ((sap (gensym "SAP-")))
+	   `(let ((,sap ,(sub-compute-call-form 'system-area-pointer)))
+	      (unless (zerop (sap-int ,sap))
+		(make-alien ',(c-type-description type)
+			    ,(c-type-size type)
+			    ,sap))))))
       (array-type
        (unless (c-type-size return-type)
 	 (error "Can't return arrays of unknown size: ~S"
-- 
GitLab