tursodatabase / libsql

libSQL is a fork of SQLite that is both Open Source, and Open Contributions.
https://turso.tech/libsql
MIT License
9.54k stars 252 forks source link

Dereference of opaque `sqlite3_context` type. #1501

Open levydsa opened 3 months ago

levydsa commented 3 months ago

sqlite3_context is a opaque type when used out of vdbe.c and should not be dereferenced, since it's definition is incomplete at comptime.

https://github.com/tursodatabase/libsql/blob/be6a38fbd4d620b3d0f0d4c8962c9d5bdc339796/libsql-sqlite3/src/alter.c#L1868-L1870

This goes under the radar because of the "amalgamation" aproach to build the source. (Yet another drawback https://github.com/tursodatabase/libsql/issues/1028#issuecomment-2185625330). The solution is to #include "vdbeInt.h", but this is very smelly. If the type should be known by the whole source, better add it to sqlite3Int.h.

The func.c includes vdbeInt.h already.

https://github.com/tursodatabase/libsql/blob/af8239736b2d67c705728be45ba2f8ebe3ae6c1a/libsql-sqlite3/src/func.c#L23

Here is some docs: https://github.com/tursodatabase/libsql/blob/be6a38fbd4d620b3d0f0d4c8962c9d5bdc339796/libsql-sqlite3/src/vdbeInt.h#L374-L398