1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Add new defenses against misuse of the C API. Ticket #870. (CVS 1906)

FossilOrigin-Name: 6ef1f662d71c75bdb7f61b2fff03f5b1b41e5586
This commit is contained in:
drh
2004-08-28 14:49:46 +00:00
parent 3d2efea4fa
commit 1bcdb0c0b2
4 changed files with 27 additions and 16 deletions

View File

@@ -138,7 +138,7 @@ int sqlite3_step(sqlite3_stmt *pStmt){
sqlite *db;
int rc;
if( p->magic!=VDBE_MAGIC_RUN ){
if( p==0 || p->magic!=VDBE_MAGIC_RUN ){
return SQLITE_MISUSE;
}
if( p->aborted ){
@@ -262,7 +262,7 @@ int sqlite3_aggregate_count(sqlite3_context *p){
*/
int sqlite3_column_count(sqlite3_stmt *pStmt){
Vdbe *pVm = (Vdbe *)pStmt;
return pVm->nResColumn;
return pVm ? pVm->nResColumn : 0;
}
/*
@@ -271,7 +271,7 @@ int sqlite3_column_count(sqlite3_stmt *pStmt){
*/
int sqlite3_data_count(sqlite3_stmt *pStmt){
Vdbe *pVm = (Vdbe *)pStmt;
if( !pVm->resOnStack ) return 0;
if( pVm==0 || !pVm->resOnStack ) return 0;
return pVm->nResColumn;
}
@@ -405,7 +405,7 @@ const void *sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){
*/
static int vdbeUnbind(Vdbe *p, int i){
Mem *pVar;
if( p->magic!=VDBE_MAGIC_RUN || p->pc>=0 ){
if( p==0 || p->magic!=VDBE_MAGIC_RUN || p->pc>=0 ){
sqlite3Error(p->db, SQLITE_MISUSE, 0);
return SQLITE_MISUSE;
}