The cmark_markdown_to_html function call uses free to release crashes
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 2k
- Forks
- 691
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 1
Description
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()
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the cmark_markdown_to_html API and inspect how the returned buffer is allocated and documented; reproduce the crash with the shown Qt caller. Determine the correct ownership and release behavior, then verify that conversion and cleanup no longer crash.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100