diff --git a/CMarkGFM.hsc b/CMarkGFM.hsc
--- a/CMarkGFM.hsc
+++ b/CMarkGFM.hsc
@@ -43,7 +43,7 @@
 import GHC.Generics (Generic)
 import Data.Data (Data)
 import Data.Typeable (Typeable)
-import Data.Text (Text, empty)
+import Data.Text (Text, empty, snoc)
 import qualified Data.Text.Foreign as TF
 import Data.ByteString.Unsafe (unsafePackMallocCString)
 import Data.Text.Encoding (decodeUtf8)
@@ -492,7 +492,7 @@
   | otherwise      = TF.peekCStringLen (str, c_strlen str)
 
 withtext :: Text -> (CString -> IO a) -> IO a
-withtext t f = TF.withCStringLen t (f . fst)
+withtext t f = TF.withCStringLen (snoc t '\0') (f . fst)
 
 foreign import ccall "string.h strlen"
     c_strlen :: CString -> Int
diff --git a/changelog b/changelog
--- a/changelog
+++ b/changelog
@@ -1,3 +1,17 @@
+cmark-gfm 0.1.8 (14 Mar 2019)
+
+  * Pull in upstream changes.
+
+cmark 0.5.6.3 (13 Mar 2019)
+
+  * Use snoc instead of <> to add the null terminator.
+
+cmark 0.5.6.2 (13 Mar 2019)
+
+  * Ensure that withtext adds a null terminator (#14).
+    This fixes a regression due to PR #13, which caused
+    random content to appear in rendered TEXT nodes.
+
 cmark-gfm 0.1.7 (13 Mar 2019)
 
   * Update to cmark-gfm 0.28.3.gfm.20.
@@ -5,14 +19,14 @@
 cmark 0.5.6.1 (11 Mar 2019)
 
   * Fix CString memory leaks (Anders Kaseorg).  The renderer functions return
-    a malloc’d string which the caller is expected to free.
+  a malloc’d string which the caller is expected to free.
 
   * Fix use-after-free bugs (Anders Kaseorg).  `useAsCString` frees the
-    CString after the IO action finishes executing, so passing `return` as that
-    action can never be correct.  To make sure the CString gets freed at the
-    right time, we need a “with”-style abstraction, not just a conversion
-    function.  While we’re here replace this with `withCStringLen`, which also
-    makes fewer copies.
+    CString after the IO action finishes executing, so passing `return` as
+    that action can never be correct.  To make sure the CString gets freed
+    at the right time, we need a “with”-style abstraction, not just a
+    conversion function.  While we’re here replace this with
+    `withCStringLen`, which also makes fewer copies.
 
   * Show node type on error for unknown node type.
 
diff --git a/cmark-gfm.cabal b/cmark-gfm.cabal
--- a/cmark-gfm.cabal
+++ b/cmark-gfm.cabal
@@ -1,12 +1,12 @@
 name:                cmark-gfm
-version:             0.1.7
+version:             0.1.8
 synopsis:            Fast, accurate GitHub Flavored Markdown parser and renderer
 description:
   This package provides Haskell bindings for
   <https://github.com/github/cmark-gfm libcmark-gfm>, the reference
   parser for <https://github.github.com/gfm/ GitHub Flavored Markdown>, a fully
   specified variant of Markdown. It includes sources for
-  libcmark-gfm (0.28.0) and does not require prior installation of the
+  libcmark-gfm (0.28.3.gfm.20) and does not require prior installation of the
   C library.
 
 homepage:            https://github.com/kivikakk/cmark-gfm-hs
@@ -14,7 +14,7 @@
 license-file:        LICENSE
 author:              Ashe Connor
 maintainer:          kivikakk@github.com
-copyright:           (C) 2015--17 John MacFarlane, (C) 2017 Ashe Connor
+copyright:           (C) 2015--17 John MacFarlane, (C) 2017--19 Ashe Connor
 category:            Text
 tested-with:         GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.2, GHC == 7.10.3
 build-type:          Simple
@@ -57,7 +57,7 @@
                      cbits/footnotes.h
                      bench/sample.md
                      bench/full-sample.md
-cabal-version:       >=1.14
+cabal-version:       1.14
 
 Source-repository head
   type:              git
