From 60eeb4a4ff217e3abbfcb6b4de94f0a6ef6d437d Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Wed, 18 Feb 2015 16:40:49 +0100 Subject: [PATCH] Issue 4293/3: smobs.tcc: robustify {mark,print}_trampoline in connection with free_smob Guilev2 has little qualms calling mark/print even after freeing a smob. So we clean out the pointer to smob data when freeing/unregistering it, and let the mark/print trampolines detect this condition and punt. --- lily/include/smobs.tcc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lily/include/smobs.tcc b/lily/include/smobs.tcc index c0a62535f5..b4dacacaa3 100644 --- a/lily/include/smobs.tcc +++ b/lily/include/smobs.tcc @@ -32,14 +32,20 @@ template SCM Smob_base::mark_trampoline (SCM arg) { - return (Super::unsmob (arg))->mark_smob (); + Super *ptr = Super::unsmob (arg); + if (ptr) + return ptr->mark_smob (); + return SCM_UNDEFINED; } template int Smob_base::print_trampoline (SCM arg, SCM port, scm_print_state *p) { - return (Super::unsmob (arg))->print_smob (port, p); + Super *ptr = Super::unsmob (arg); + if (ptr) + return ptr->print_smob (port, p); + return 0; } template @@ -96,6 +102,7 @@ Smob_base::unregister_ptr (SCM obj) { Super *p = Super::unchecked_unsmob (obj); scm_gc_unregister_collectable_memory (p, sizeof (*p), smob_name_.c_str ()); + SCM_SET_SMOB_DATA (obj, static_cast (0)); return p; } -- 2.39.2