Skip to content

Commit 008d466

Browse files
authored
fix: pass correct pointer to cleanup in ensure_vector_match error path
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.
1 parent a2dd24f commit 008d466

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sqlite-vec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "sqlite-vec.h"
1+
f#include "sqlite-vec.h"
22

33
#include <assert.h>
44
#include <errno.h>
@@ -1016,7 +1016,7 @@ int ensure_vector_match(sqlite3_value *aValue, sqlite3_value *bValue, void **a,
10161016
if (rc != SQLITE_OK) {
10171017
*outError = sqlite3_mprintf("Error reading 2nd vector: %s", error);
10181018
sqlite3_free(error);
1019-
aCleanup(a);
1019+
aCleanup(*a);
10201020
return SQLITE_ERROR;
10211021
}
10221022

0 commit comments

Comments
 (0)