From 23d01a29cef730e5d4c107ffe56410af5006151d Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 22 Mar 2023 01:43:45 +0100 Subject: [PATCH] Use the size struct member when parsing markdown in MarkdownRenderer. --- modules/web/html/markdown_renderer.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/web/html/markdown_renderer.cpp b/modules/web/html/markdown_renderer.cpp index 9ad364b49..4fe539f19 100644 --- a/modules/web/html/markdown_renderer.cpp +++ b/modules/web/html/markdown_renderer.cpp @@ -111,21 +111,20 @@ String MarkdownRenderer::render_to_html(const String &markdown) { hoedown_document *document = hoedown_document_new(renderer, static_cast(hoedown_ext_flags), _max_nesting); - //#define DEF_IUNIT 1024 - hoedown_buffer *html = hoedown_buffer_new(1024); + hoedown_buffer *html = hoedown_buffer_new(16); CharString csmd = markdown.utf8(); hoedown_document_render(document, html, reinterpret_cast(csmd.get_data()), csmd.length()); - String html_str = String::utf8(reinterpret_cast(html->data)); + String html_str = String::utf8(reinterpret_cast(html->data), html->size); if (_use_smartypants) { CharString cshtml = html_str.utf8(); hoedown_html_smartypants(html, reinterpret_cast(cshtml.get_data()), cshtml.length()); - html_str = String::utf8(reinterpret_cast(html->data)); + html_str = String::utf8(reinterpret_cast(html->data), html->size); } hoedown_buffer_free(html);