Skip to content

Pass correct pointer to cleanup in ensure_vector_match error path#3

Merged
vlasky merged 1 commit intovlasky:mainfrom
renatgalimov:main
Feb 28, 2026
Merged

Pass correct pointer to cleanup in ensure_vector_match error path#3
vlasky merged 1 commit intovlasky:mainfrom
renatgalimov:main

Conversation

@renatgalimov
Copy link
Copy Markdown

When the second vector fails to parse in ensure_vector_match(), the cleanup function for the first vector was called with 'a' (void**) instead of 'a' (void). This caused sqlite3_free to be called with a stack address instead of the heap-allocated vector, resulting in a crash:

malloc: Non-aligned pointer being freed
Fatal error 6: Aborted

The fix dereferences the pointer correctly, matching how cleanup is done in other error paths.

This fix has a unit test that will crash without the patch.

When the second vector fails to parse in ensure_vector_match(), the cleanup function for the first vector was called with 'a' (void**) instead of '*a' (void*). This caused sqlite3_free to be called with a stack address instead of the heap-allocated vector, resulting in a crash:

    malloc: Non-aligned pointer being freed
    Fatal error 6: Aborted

The fix dereferences the pointer correctly, matching how cleanup is
done in other error paths.

This fix has a unit test that will crash without the patch.
Copy link
Copy Markdown

@mceachen mceachen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Thanks for sharing!

@vlasky vlasky merged commit c069089 into vlasky:main Feb 28, 2026
@vlasky
Copy link
Copy Markdown
Owner

vlasky commented Feb 28, 2026

@renatgalimov thank you for your contribution!

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