The cmark_markdown_to_html function call uses free to release crashes
QString DeepSeekWidgetUI::convertMarkdownToHtml(const QString& markdown) { QByteArray byteArray = markdown.toUtf8(); const char* markdownCString = byteArray.constData();
char* html = cmark_markdown_to_html(markdownCString, strlen(markdownCString), CMARK_OPT_DEFAULT);
if (html == NULL)
{
return markdown;
}
QString htmlText = QString::fromUtf8(html);
free(html);
return htmlText;
}
After calling the cmark_markdown_to_html function, I copied the data to the QString, then released the memory and crashed directly. I thought it was a problem with the QString::fromUtf8() function, so I tested it and executed free() before QString::fromUtf8(), and it crashed as well.
This is the result of the call after QString::fromUtf8()
This is the result of the call before QString::fromUtf8()
I also had this problem. I had thought there's no need to call free().
You need to use cmark_node_free I think.