From 99e639c86152c2bd13563e78be7f0b3c039ecde7 Mon Sep 17 00:00:00 2001 From: Krasimir Angelov Date: Sun, 9 Jan 2022 07:37:03 +0100 Subject: [PATCH] handle failed linearization in tabularLinearize --- src/runtime/haskell/PGF2.hsc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/runtime/haskell/PGF2.hsc b/src/runtime/haskell/PGF2.hsc index 8f5001eaa..3f4b7daa4 100644 --- a/src/runtime/haskell/PGF2.hsc +++ b/src/runtime/haskell/PGF2.hsc @@ -671,7 +671,10 @@ tabularLinearize c e = withForeignPtr (c_revision c) $ \c_revision -> bracket (newStablePtr e) freeStablePtr $ \c_e -> withForeignPtr marshaller $ \m -> - bracket (withPgfExn "tabularLinearize" (pgf_tabular_linearize (c_db c) c_revision c_e nullPtr m)) free peekTable + bracket (withPgfExn "tabularLinearize" (pgf_tabular_linearize (c_db c) c_revision c_e nullPtr m)) free $ \c_texts -> do + if c_texts == nullPtr + then [] + else peekTable c_texts where peekTable c_texts = do c_field <- peekElemOff c_texts 0