From 4fbe344df43ed7f60a3d3a53981088334cb709fc Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sat, 31 Dec 2016 02:25:16 +0100 Subject: Change types for source map offsets (#174) * Improve strbuf guarantees Introduce BUFSIZE_MAX macro and make sure that the strbuf implementation can handle strings up to this size. * Abort early if document size exceeds internal limit * Change types for source map offsets Switch to size_t for the public API, making the public headers C89-compatible again. Switch to bufsize_t internally, reducing memory usage and improving performance on 32-bit platforms. * Make parser return NULL on internal index overflow Make S_parser_feed set an error and ignore subsequent chunks if the total input document size exceeds an internal limit. Make cmark_parser_finish return NULL if an error was encountered. Add public API functions to retrieve error code and error message. strbuf overflow in renderers and OOM in parser or renderers still cause an abort. --- src/cmark.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/cmark.c') diff --git a/src/cmark.c b/src/cmark.c index 2ef6cb4..da93abe 100644 --- a/src/cmark.c +++ b/src/cmark.c @@ -36,6 +36,9 @@ char *cmark_markdown_to_html(const char *text, size_t len, int options) { char *result; doc = cmark_parse_document(text, len, options); + if (doc == NULL) { + return NULL; + } result = cmark_render_html(doc, options); cmark_node_free(doc); -- cgit v1.2.3