From f9d699facc2a48022d44a67b6ef8eb76a6ca1233 Mon Sep 17 00:00:00 2001 From: defanor Date: Sun, 22 Apr 2018 02:26:26 +0300 Subject: Fix an occasional segfault Not sure why it happens, but calls to raptor_free_uri via finalizers led to segfaults, and it helped to call a finalizer manually from statementToTriple. --- Redland/Util.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Redland/Util.hs') diff --git a/Redland/Util.hs b/Redland/Util.hs index 0940cfc..c7862be 100644 --- a/Redland/Util.hs +++ b/Redland/Util.hs @@ -84,7 +84,7 @@ redlandNodeToNode rn = do (_, Just t) -> Just . XMLSchema <$> uriAsString t _ -> pure Nothing pure $ LiteralNode litVal nType - _ -> ResourceNode <$> (nodeGetURI rn >>= uriAsString) + _ -> ResourceNode <$> withNew (nodeGetURI rn) uriAsString -- | A conversion function. nodeToRedlandNode :: ForeignPtr RedlandWorld @@ -186,7 +186,11 @@ statementToTriple statement = do componentToTriple f = do c <- f statement case c of - Just c' -> Just <$> redlandNodeToNode c' + Just c' -> do + n <- redlandNodeToNode c' + -- segfaulting without finalization here, not sure why. + finalizeForeignPtr c' + pure $ Just n Nothing -> pure Nothing -- | A conversion function. -- cgit v1.2.3