cmark

My personal build of CMark ✏️

Commit
29c46c5aeda66e9c454ac8d802e65692d0bab566
Parent
5255e2d5717dc7a265ca79404d387ef8abe8c004
Author
Nick Wellnhofer <wellnhofer@aevum.de>
Date

Correctly initialize chunk in S_process_line (#170)

The `alloc` member wasn't initialized. This also allows to add an assertion in `chunk_rtrim` which doesn't work for alloced chunks.

Diffstat

2 files changed, 3 insertions, 0 deletions

Status File Name N° Changes Insertions Deletions
Modified src/blocks.c 1 1 0
Modified src/chunk.h 2 2 0
diff --git a/src/blocks.c b/src/blocks.c
@@ -1157,6 +1157,7 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
 
   input.data = parser->curline.ptr;
   input.len = parser->curline.size;
+  input.alloc = 0;
 
   parser->line_number++;
 
diff --git a/src/chunk.h b/src/chunk.h
@@ -37,6 +37,8 @@ static CMARK_INLINE void cmark_chunk_ltrim(cmark_chunk *c) {
 }
 
 static CMARK_INLINE void cmark_chunk_rtrim(cmark_chunk *c) {
+  assert(!c->alloc);
+
   while (c->len > 0) {
     if (!cmark_isspace(c->data[c->len - 1]))
       break;