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: delete validator before clear #2244

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

junwha0511
Copy link

Hi, we found an incorrect use of Clear API of the allocator, which leads to Use-After-Free in schematest.

At test/perftest/schematest.cpp:208, the validator is constructed with validatorAllocator, and the chunks allocated during line 210 to line 213 are collected by the Clear API at line 214 as the for statement is ended.
However, the destructor of GeneriSchemaValidator is called at line 215, leading to invalid accesses to the chunks(Stack).

To avoid this issue, I added explicit delete to the validator before the Clear API call.

Thank you very much for taking the time to revise this issue!

@miloyip
Copy link
Collaborator

miloyip commented Dec 26, 2023

I think may just add a block {} to force destructing the validator first.

@junwha0511
Copy link
Author

Hi @miloyip, Thank you for the feedback! I changed the patch as you commented.

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.

None yet

2 participants