From c0e390f745539d04367cb56323799e246008cc9e Mon Sep 17 00:00:00 2001 From: Martin Mitas Date: Sun, 21 Jan 2024 11:42:30 +0100 Subject: [PATCH 1/3] md_is_html_cdata: Remove not needed max_end shrinking. md_scan_for_html_closer() handles that internally. --- src/md4c.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/md4c.c b/src/md4c.c index 17709a07..6425d0c1 100644 --- a/src/md4c.c +++ b/src/md4c.c @@ -1275,9 +1275,6 @@ md_is_html_cdata(MD_CTX* ctx, const MD_LINE* lines, int n_lines, OFF beg, OFF ma return FALSE; off += open_size; - if(lines[n_lines-1].end < max_end) - max_end = lines[n_lines-1].end - 2; - return md_scan_for_html_closer(ctx, _T("]]>"), 3, lines, n_lines, off, max_end, p_end, &ctx->html_cdata_horizon); } From 9381eb8556c112a4ccf4e802b3728a563ceb0d5d Mon Sep 17 00:00:00 2001 From: Martin Mitas Date: Sun, 21 Jan 2024 11:45:02 +0100 Subject: [PATCH 2/3] md_process_table_row: Remove not needed freeing of ptr_stack. This is already handled universally in md_process_normal_block_contents() which is called from md_process_table_row() via md_process_table_cell(). --- src/md4c.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/md4c.c b/src/md4c.c index 6425d0c1..0907286c 100644 --- a/src/md4c.c +++ b/src/md4c.c @@ -4596,11 +4596,6 @@ md_process_table_row(MD_CTX* ctx, MD_BLOCKTYPE cell_type, OFF beg, OFF end, abort: free(pipe_offs); - /* Free any temporary memory blocks stored within some dummy marks. */ - for(i = ctx->ptr_stack.top; i >= 0; i = ctx->marks[i].next) - free(md_mark_get_ptr(ctx, i)); - ctx->ptr_stack.top = -1; - ctx->table_cell_boundaries_head = -1; ctx->table_cell_boundaries_tail = -1; From 58c87ed1f8b4b7e817f85253c61b263692909c6f Mon Sep 17 00:00:00 2001 From: Martin Mitas Date: Sun, 21 Jan 2024 11:50:18 +0100 Subject: [PATCH 3/3] md_opener_stack: Mark the default branch of switch as unreachable. We were returning NULL previously, but that would lead to a crash anyway; all callsites expect to get their respective stack anyway and anything else would mean we are internally broken. --- src/md4c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/md4c.c b/src/md4c.c index 0907286c..3093e2aa 100644 --- a/src/md4c.c +++ b/src/md4c.c @@ -2555,7 +2555,7 @@ md_opener_stack(MD_CTX* ctx, int mark_index) case _T('!'): case _T('['): return &BRACKET_OPENERS; - default: return NULL; + default: MD_UNREACHABLE(); } }