summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorArda Cinar <kuzux92@gmail.com>2022-12-15 18:45:31 +0300
committerLinus Groh <mail@linusgroh.de>2022-12-15 16:30:21 +0000
commite2566d5126e050691db2946126a92baec045588a (patch)
treed0c05e4e566a8a281778e24bcd550706a60a4d3e /Userland/Libraries
parent80563120e23a3fe49c18524573fd0ca6785fb2e0 (diff)
downloadserenity-e2566d5126e050691db2946126a92baec045588a.zip
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.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibMarkdown/ContainerBlock.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibMarkdown/ContainerBlock.cpp b/Userland/Libraries/LibMarkdown/ContainerBlock.cpp
index 99c6f4af64..f137e470d3 100644
--- a/Userland/Libraries/LibMarkdown/ContainerBlock.cpp
+++ b/Userland/Libraries/LibMarkdown/ContainerBlock.cpp
@@ -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())