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

Memory leak in bson_as_json #1

Open
unalos opened this issue Dec 22, 2018 · 3 comments
Open

Memory leak in bson_as_json #1

unalos opened this issue Dec 22, 2018 · 3 comments

Comments

@unalos
Copy link

unalos commented Dec 22, 2018

The bson_as_json C stub returns a char *. The documentation of BSon states that such strings/pointers must be deallocated with free(). However the pointer becomes owned by Idris when returning from the call to the C stub. As far as I see it, Idris doesn't free() the pointer.

@machunter
Copy link
Owner

Thank you. I'm aware. I was experimenting and didn't pay much attention to that aspect. When I get back into this I'll try to come up with some strategy.

@unalos
Copy link
Author

unalos commented Dec 23, 2018

Then you may be interested as to how I fixed it in my own code.

https://github.com/unalos/idris-mongo/blob/8b6202f26bde73ca58bb285b7c830863afc42e1d/idris_bson.c#L36

@machunter
Copy link
Owner

Thanks! I didn't know of get_vm() (You're way ahead of me)

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