From 81002955670420b2340d601607c7d7aae24fc0d3 Mon Sep 17 00:00:00 2001 From: Joshua Suskalo Date: Fri, 1 Oct 2021 12:03:25 -0500 Subject: [PATCH] Ensure serializing nil as a pointer returns null --- src/clj/coffi/mem.clj | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/clj/coffi/mem.clj b/src/clj/coffi/mem.clj index ff0ce26..c885226 100644 --- a/src/clj/coffi/mem.clj +++ b/src/clj/coffi/mem.clj @@ -323,13 +323,14 @@ (defmethod serialize* ::pointer [obj type scope] - (when-not (null? obj) + (if-not (null? obj) (if (sequential? type) (with-acquired [scope] (let [segment (alloc-instance (second type) scope)] (serialize-into obj (second type) segment scope) (address-of segment))) - obj))) + obj) + (MemoryAddress/NULL))) (defmulti serialize-into "Writes a serialized version of the `obj` to the given `segment`.