diff --git a/libc3/facts_cursor.c b/libc3/facts_cursor.c
index 2f542c1..979531e 100644
--- a/libc3/facts_cursor.c
+++ b/libc3/facts_cursor.c
@@ -33,7 +33,8 @@ s_facts_cursor * facts_cursor_init (s_facts *facts,
assert(cursor);
assert(index);
pred = skiplist_pred__fact(index, start);
- assert(pred);
+ if (! pred)
+ return NULL;
cursor->index = index;
cursor->node = SKIPLIST_NODE_NEXT__fact(pred, 0);
skiplist_node_delete__fact(pred);
@@ -55,7 +56,10 @@ s_facts_cursor * facts_cursor_init (s_facts *facts,
cursor->var_predicate = NULL;
cursor->var_object = NULL;
cursor->facts = facts;
- facts_cursor_lock_init(cursor);
+ if (! facts_cursor_lock_init(cursor)) {
+ facts_cursor_clean(cursor);
+ return NULL;
+ }
return cursor;
}
diff --git a/libc3/skiplist.c.in b/libc3/skiplist.c.in
index 24d5356..92d0ff2 100644
--- a/libc3/skiplist.c.in
+++ b/libc3/skiplist.c.in
@@ -170,8 +170,9 @@ skiplist_pred___NAME$ (s_skiplist___NAME$ *skiplist, _TYPE$ _NAME$)
assert(skiplist);
level = skiplist->max_height;
pred = skiplist_node_new___NAME$(NULL, skiplist->max_height);
+ if (! pred)
+ return NULL;
node = skiplist->head;
- assert(pred);
while (level--) {
n = node;
while (n && skiplist->compare(_NAME$, n->_NAME$) > 0) {
diff --git a/libc3/skiplist__fact.c b/libc3/skiplist__fact.c
index 9b59ff9..32b4994 100644
--- a/libc3/skiplist__fact.c
+++ b/libc3/skiplist__fact.c
@@ -170,8 +170,9 @@ skiplist_pred__fact (s_skiplist__fact *skiplist, s_fact * fact)
assert(skiplist);
level = skiplist->max_height;
pred = skiplist_node_new__fact(NULL, skiplist->max_height);
+ if (! pred)
+ return NULL;
node = skiplist->head;
- assert(pred);
while (level--) {
n = node;
while (n && skiplist->compare(fact, n->fact) > 0) {