Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix table cannot be recoginsed without empty line #154

Merged
merged 7 commits into from
May 8, 2019
Merged

Fix table cannot be recoginsed without empty line #154

merged 7 commits into from
May 8, 2019

Conversation

jinhucheung
Copy link

fix #141

@jinhucheung jinhucheung changed the title Fix table can not be recoginsed without empty line Fix table cannot be recoginsed without empty line May 6, 2019
Copy link

@kivikakk kivikakk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great -- thank you so much. I'm going to run some fuzzing on this to make sure it holds up OK, but it looks good to me. 👍

@@ -150,7 +150,7 @@ Hello!

| _abc_ | セン |
| ----- | ---- |
| this row has a space at the end | |
| this row has a space at the end | |
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| this row has a space at the end | |
| this row has a space at the end | |

This was probably removed by accident.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is "whitespace trimming" on vscode ❤️


paragraph = cmark_node_new_with_mem(CMARK_NODE_PARAGRAPH, parser->mem);

paragraph_content = unescape_pipes(parser->mem, parent_string, paragraph_offset);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed redundant type conversions 7f69c4e

kivikakk and others added 2 commits May 8, 2019 11:09
`cmark_node_set_string_content` allocates and copies the data in
`paragraph_content` so it is not needed afterwards.

```
=================================================================
==14==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    0 0x4dd330 in calloc /src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:97
    1 0x59e243 in xcalloc /src/octofuzz/src/cmark.c:18:15
    2 0x58fd75 in unescape_pipes /src/octofuzz/extensions/table.c:95:39
    3 0x58fd75 in try_inserting_table_header_paragraph /src/octofuzz/extensions/table.c:187
    4 0x58fd75 in try_opening_table_header /src/octofuzz/extensions/table.c:254
    5 0x58fd75 in try_opening_table_block /src/octofuzz/extensions/table.c:370
    6 0x5b22d5 in open_new_blocks /src/octofuzz/src/blocks.c:1275:27
    7 0x5b22d5 in S_process_line /src/octofuzz/src/blocks.c:1465
    8 0x5aa7f0 in cmark_parser_finish /src/octofuzz/src/blocks.c:1492:5
    9 0x58f2fc in LLVMFuzzerTestOneInput /src/octofuzz/test/cmark-fuzz.c:46:23

Indirect leak of 8 byte(s) in 1 object(s) allocated from:
    0 0x4dd580 in realloc /src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:107
    1 0x59e2d3 in xrealloc /src/octofuzz/src/cmark.c:27:19
    2 0x640364 in cmark_strbuf_grow /src/octofuzz/src/buffer.c:57:31
    3 0x640364 in cmark_strbuf_init /src/octofuzz/src/buffer.c:31
    4 0x58fd8b in unescape_pipes /src/octofuzz/extensions/table.c:98:3
    5 0x58fd8b in try_inserting_table_header_paragraph /src/octofuzz/extensions/table.c:187
    6 0x58fd8b in try_opening_table_header /src/octofuzz/extensions/table.c:254
    7 0x58fd8b in try_opening_table_block /src/octofuzz/extensions/table.c:370
    8 0x5b22d5 in open_new_blocks /src/octofuzz/src/blocks.c:1275:27
    9 0x5b22d5 in S_process_line /src/octofuzz/src/blocks.c:1465
    10 0x5aa7f0 in cmark_parser_finish /src/octofuzz/src/blocks.c:1492:5
    11 0x58f2fc in LLVMFuzzerTestOneInput /src/octofuzz/test/cmark-fuzz.c:46:23

SUMMARY: AddressSanitizer: 32 byte(s) leaked in 2 allocation(s).
```
@kivikakk
Copy link

kivikakk commented May 8, 2019

I've pushed 15e924d from @philipturnbull, who found a memory leak while fuzzing this branch.

@kivikakk kivikakk merged commit ef13dc5 into github:master May 8, 2019
@kivikakk
Copy link

kivikakk commented May 8, 2019

@jinhucheung Thank you for your PR!

@jinhucheung jinhucheung deleted the fix-table-not-recognised-without-empty-line branch May 8, 2019 02:11
kivikakk added a commit to kivikakk/comrak that referenced this pull request Apr 9, 2021
talum pushed a commit that referenced this pull request Sep 14, 2021
* fix(table): recoginse-without-empty-line (#141)

* fix(table): fix bufsize_t not convert to uint16_t

* fix(table): fix uint16_6 not convert to int

* fix(table): fix uint16_6 not convert to int

* fix(table): clear unused type conversion

* restore whitespace

* Always free `paragraph_content`

`cmark_node_set_string_content` allocates and copies the data in
`paragraph_content` so it is not needed afterwards.

```
=================================================================
==14==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    0 0x4dd330 in calloc /src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:97
    1 0x59e243 in xcalloc /src/octofuzz/src/cmark.c:18:15
    2 0x58fd75 in unescape_pipes /src/octofuzz/extensions/table.c:95:39
    3 0x58fd75 in try_inserting_table_header_paragraph /src/octofuzz/extensions/table.c:187
    4 0x58fd75 in try_opening_table_header /src/octofuzz/extensions/table.c:254
    5 0x58fd75 in try_opening_table_block /src/octofuzz/extensions/table.c:370
    6 0x5b22d5 in open_new_blocks /src/octofuzz/src/blocks.c:1275:27
    7 0x5b22d5 in S_process_line /src/octofuzz/src/blocks.c:1465
    8 0x5aa7f0 in cmark_parser_finish /src/octofuzz/src/blocks.c:1492:5
    9 0x58f2fc in LLVMFuzzerTestOneInput /src/octofuzz/test/cmark-fuzz.c:46:23

Indirect leak of 8 byte(s) in 1 object(s) allocated from:
    0 0x4dd580 in realloc /src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:107
    1 0x59e2d3 in xrealloc /src/octofuzz/src/cmark.c:27:19
    2 0x640364 in cmark_strbuf_grow /src/octofuzz/src/buffer.c:57:31
    3 0x640364 in cmark_strbuf_init /src/octofuzz/src/buffer.c:31
    4 0x58fd8b in unescape_pipes /src/octofuzz/extensions/table.c:98:3
    5 0x58fd8b in try_inserting_table_header_paragraph /src/octofuzz/extensions/table.c:187
    6 0x58fd8b in try_opening_table_header /src/octofuzz/extensions/table.c:254
    7 0x58fd8b in try_opening_table_block /src/octofuzz/extensions/table.c:370
    8 0x5b22d5 in open_new_blocks /src/octofuzz/src/blocks.c:1275:27
    9 0x5b22d5 in S_process_line /src/octofuzz/src/blocks.c:1465
    10 0x5aa7f0 in cmark_parser_finish /src/octofuzz/src/blocks.c:1492:5
    11 0x58f2fc in LLVMFuzzerTestOneInput /src/octofuzz/test/cmark-fuzz.c:46:23

SUMMARY: AddressSanitizer: 32 byte(s) leaked in 2 allocation(s).
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Table is not rendered at first non-empty line
3 participants