Skip to content

Conversation

@Alexk-195
Copy link
Contributor

Fixing potential crash in readline function caused by neglecting result of realloc.
sqlite3 crashed if using "select rowid, value, name from fileio_scan('README.md');"

Problem found and fixed using Claude. Here the explanation:
The issue here is that when realloc is called, it may return a new pointer while freeing the old one. If this happens, p would still be pointing to the old memory block, which has been freed. Continuing to use p after this point could lead to memory corruption.
The correct approach would be to adjust p after realloc to point to the corresponding position in the newly allocated memory.

@nalgeon nalgeon merged commit df98916 into nalgeon:main May 2, 2025
2 of 3 checks passed
@nalgeon
Copy link
Owner

nalgeon commented May 2, 2025

Thank you!

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.

3 participants