SQLite Forum

sqlite3_exec: Any way to validate the first argument?
Login
I doubt that this is news to Ryan; I say the following to avoid any interpretation that seems to condone any invitation to undefined behavior.

If a sqlite3 pointer was returned (as an out parameter) by the sqlite3_open\*() family of APIs, then a test such as Ryan's simple SELECR is fine (but pretty much useless with respect to proving anything reasonably in doubt.)

However, if you have something that you suspect is not a return from one of the sqlite3_open\*() functions, passing it to any SQLite library API which expects a sqlite3 pointer, in lieu of such a pointer, is a very bad practice and should **never** be done in released code held out as the creation of any responsible programmer(s). Such folk do not court undefined behavior and strive to avoid it. Yet, that is exactly what such a "test" invites.