cmark

My personal build of CMark ✏️

Commit
d94d592d2b76c2f0c4bc27ab74ff145ee1e390f5
Parent
3f251cdca271ddb79d06fb8fc101499d0e9a3021
Author
John MacFarlane <fiddlosopher@gmail.com>
Date

Avoid potential memory leak.

Previously, if malloc failed to allocate 'newstack', the function would return without freeing 'stack'. Pointed out by clang static analyzer.

Diffstat

1 file changed, 1 insertion, 2 deletions

Status File Name N° Changes Insertions Deletions
Modified src/blocks.c 3 1 2
diff --git a/src/blocks.c b/src/blocks.c
@@ -302,7 +302,7 @@ static void process_inlines(cmark_node* cur, cmark_reference_map *refmap)
 
 		if (cur->first_child) {
 			newstack = (block_stack*)malloc(sizeof(block_stack));
-			if (newstack == NULL) return;
+			if (newstack == NULL) break;
 			newstack->previous = stack;
 			stack = newstack;
 			stack->next_sibling = cur->next;
@@ -840,4 +840,3 @@ cmark_node *cmark_finish(cmark_doc_parser *parser)
 #endif
 	return parser->root;
 }
-