Skip to content

Commit

Permalink
Merge pull request #14 from kivikakk/latest-upstream
Browse files Browse the repository at this point in the history
Latest upstream
  • Loading branch information
Ashe Connor authored Mar 14, 2019
2 parents 8c3e26b + e3cd5c9 commit b3fd73b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions CMarkGFM.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import Data.Maybe (fromMaybe)
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)
Expand Down Expand Up @@ -492,7 +492,7 @@ totext str
| 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
Expand Down
22 changes: 16 additions & 6 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
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.

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.

Expand Down
2 changes: 1 addition & 1 deletion cmark-gfm.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extra-source-files: README.md
cbits/footnotes.h
bench/sample.md
bench/full-sample.md
cabal-version: >=1.14
cabal-version: 1.14

Source-repository head
type: git
Expand Down

0 comments on commit b3fd73b

Please sign in to comment.