1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:57:44 +00:00

LibMarkdown: Prevent a crash when rendering code blocks to console

When parsing a code block not in a section (in a file without a
heading), the parser would initialize the code block with an
uninitialized (invalid) value for current_section. Accessing this value
would later cause a segmentation fault in render_to_terminal.
This commit is contained in:
Arda Cinar 2022-12-15 18:45:31 +03:00 committed by Linus Groh
parent 80563120e2
commit e2566d5126

View file

@ -91,7 +91,7 @@ OwnPtr<ContainerBlock> ContainerBlock::parse(LineIterator& lines)
NonnullOwnPtrVector<Block> blocks;
StringBuilder paragraph_text;
Heading* current_section;
Heading* current_section = nullptr;
auto flush_paragraph = [&] {
if (paragraph_text.is_empty())