-
-
Notifications
You must be signed in to change notification settings - Fork 564
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
Memory leak in cmark_consolidate_text_nodes
#32
Comments
This can also be revealed by
I have improved 'make leakcheck' to detect this case. Could you say more about your "more proper solution"? I |
Well, what I tried was adding a I'm not sure about it, but it looks like after your fix it still double-copies the string (allocates the string buffer, then allocates a copy, then frees the first copy). |
This improves on #32, I think. @elibarzilay, does this look better? We now avoid the allocations associated with cmark_get_literal, and copy directly from the chunk to the buffer.
Also clean up CMakeLists considerably.
AFAICT, the call it does a call to
cmark_node_set_literal
copies the string frombuf
, but that string is never copied. It's easy to verify the leak with running it in a loop and looking at the memory (which is how I caught it) then adding afree
for the detached string and the leak is gone.[I'd submit it as a PR, but it seems silly to put stuff in an allocated string, then copying it and freeing the first. A more proper solution would be some way to signal a request to not copy the text (which
cmark_node_set_literal
could get as a new argument which will be passed on tocmark_chunk_set_cstr
) but that's an API change, so I'm just reporting it...]The text was updated successfully, but these errors were encountered: