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

Missing #include in parser.h #287

Closed
phoney opened this issue Mar 22, 2019 · 1 comment
Closed

Missing #include in parser.h #287

phoney opened this issue Mar 22, 2019 · 1 comment

Comments

@phoney
Copy link

phoney commented Mar 22, 2019

The Down project uses the code from the cmark project (currently it uses the code pulled from the v0.28.3 tag). A crashing bug was reported to Down that I've tracked down to a missing #include in parser.h. johnxnguyen/Down#126
The stack trace for the crash shows:

0 xcalloc
1 cmark_chunk_free
2 reference_free

cmark_chunk_free() doesn't call xcalloc. It calls mem->free(). Because of the missing #include the compiler calls mem-> xcalloc() instead of mem->free(). Making the #includes in parser.h like this fixes the crash:

#include "references.h"
#include "node.h"
#include "buffer.h"
#include "memory.h"

Using the struct keyword on this line in parser.h contributes to this issue
struct cmark_reference_map *refmap;

Reordering the #includes in references.c also fixes this if references.h comes before parser.h. I'm not sure why references.h has to go first in parser.h to fix this though.

I don't know if there's something about how cmark is compiled in the Down project that causes this or if the reference_free() function isn't called with most markdown or if there's some other reason this hasn't been noticed before.

Hope you can fix this.

@jgm jgm closed this as completed in 01be842 Mar 23, 2019
@jgm
Copy link
Member

jgm commented Mar 23, 2019

Not sure why it hasn't come up before -- it does seem that this include is necessary!

talum referenced this issue in github/cmark-gfm Sep 14, 2021
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

No branches or pull requests

2 participants