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

possible memory leak when calling _jsonb_escape #3

Closed
anibalportero opened this issue Aug 31, 2022 · 2 comments
Closed

possible memory leak when calling _jsonb_escape #3

anibalportero opened this issue Aug 31, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@anibalportero
Copy link

Hi!

We are using your amazing library and found a potential mem leak. I'm not sure the patch we prepared to solve it is good though:

pantacor#2

Seems like _jsonb_escape was using the complete bufsize but buf was passed as buf + b->pos. So could _jsonb_escape be writing beyond the limits of buf?

To give some context, we are allocating an initial buffer that we resize if any of the build functions return JSONB_ERROR_NOMEM.

@lcsmuller
Copy link
Owner

Good catch - I hope I can try your solution later today and then give you a follow-up on it!

Thanks for letting me know, always a great feeling seeing my stuff used by awesome projects.

@lcsmuller lcsmuller self-assigned this Aug 31, 2022
@lcsmuller lcsmuller added the bug Something isn't working label Aug 31, 2022
@lcsmuller
Copy link
Owner

@anibalportero Should be fixed now, thank you for bringing this to my attention!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants