From 2c2533eda8ff59561441bb597e162ae4bf1c6d98 Mon Sep 17 00:00:00 2001 From: Joachim Klein Date: Fri, 7 Aug 2015 09:37:26 +0000 Subject: [PATCH] JDD: Check for NULL ptr in Ref/Deref Normally, we should catch the construction of JDDNodes with NULL pointers beforehand, but for robustness we make sure that we do not call Cudd_Ref and Cudd_Deref for a NULL DdNode*, as that leads to SIGSEGV crashes. git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@10473 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/src/jdd/JDD.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/prism/src/jdd/JDD.java b/prism/src/jdd/JDD.java index 3ad0ecfb..3880eaea 100644 --- a/prism/src/jdd/JDD.java +++ b/prism/src/jdd/JDD.java @@ -265,9 +265,17 @@ public class JDD */ public static void Ref(JDDNode dd) { + long ptr = dd.ptr(); + // For robustness, catch NULL pointer + // In general, this should not happen, + // as constructing a JDDNode with NULL + // pointer should not happen... + if (ptr == 0) { + throw new CuddOutOfMemoryException(); + } if (DebugJDD.debugEnabled) DebugJDD.increment(dd); - DD_Ref(dd.ptr()); + DD_Ref(ptr); } /** @@ -276,9 +284,17 @@ public class JDD */ public static void Deref(JDDNode dd) { + long ptr = dd.ptr(); + // For robustness, catch NULL pointer + // In general, this should not happen, + // as constructing a JDDNode with NULL + // pointer should not happen... + if (ptr == 0) { + throw new CuddOutOfMemoryException(); + } if (DebugJDD.debugEnabled) DebugJDD.decrement(dd); - DD_Deref(dd.ptr()); + DD_Deref(ptr); } /**