Repository navigation
Conversation
ly_in_memory() and ly_in_memory_chunk() are documented to return the previous starting address, which the caller is responsible to free, but they returned the current read position. After some data were read or parsed, the returned pointer pointed inside the previous data and freeing it was an invalid free.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ly_in_memory()andly_in_memory_chunk()are documented to return the "Previous starting address to read data from", and "the caller is responsible to free the data in case of changing string pointer". Once something has been read from the input (ly_in_read(), or a parser such aslyd_parse_data()), they return the current read position instead, so freeing the returned pointer as documented is an invalid free.On devel f45939c this prints
returned data + 2and then ASan reportsattempting free on address which was not malloc()-ed, 2 bytes inside the 7-byte block; a build without sanitizers aborts withfree(): invalid pointer. After a successfullyd_parse_data()the returned pointer is at the end of the parsed data.Cause: both functions return
in->currentinstead ofin->start.Fix: return
in->start. Before anything is read the two are equal, so the existing cases do not change. The query form (strormemNULL) now also returns the start of the data. The new cases intest_input_memread two bytes before changing the input; they fail on the current tree and pass with the fix.Tested on devel f45939c with clang 21,
-fsanitize=address,undefined,ENABLE_TESTS=ON:ctestpasses (70 tests).