mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-08 03:22:21 +03:00
New assert()s added to verify that the Expr.token value is used correctly. Ticket #3743. (CVS 6378)
FossilOrigin-Name: cf3d84ab73b7f519921a984f88bdad81996a3a82
This commit is contained in:
11
src/expr.c
11
src/expr.c
@@ -12,7 +12,7 @@
|
||||
** This file contains routines used for analyzing expressions and
|
||||
** for generating VDBE code that evaluates expressions in SQLite.
|
||||
**
|
||||
** $Id: expr.c,v 1.422 2009/03/24 15:08:10 drh Exp $
|
||||
** $Id: expr.c,v 1.423 2009/03/24 15:31:28 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@@ -408,17 +408,19 @@ Expr *sqlite3Expr(
|
||||
assert( pToken->dyn==0 );
|
||||
pNew->span = *pToken;
|
||||
|
||||
/* The pToken->z value is constant and must not change. But
|
||||
** this expression might be passed to sqlite3DequoteExpr() which
|
||||
/* The pToken->z value is read-only. But the new expression
|
||||
** node created here might be passed to sqlite3DequoteExpr() which
|
||||
** will attempt to modify pNew->token.z. Hence, if the token
|
||||
** is quoted, make a copy now so that DequoteExpr() will change
|
||||
** the copy rather than the original (read-only) text.
|
||||
** the copy rather than the original text.
|
||||
*/
|
||||
if( pToken->n>=2
|
||||
&& ((c = pToken->z[0])=='\'' || c=='"' || c=='[' || c=='`') ){
|
||||
sqlite3TokenCopy(db, &pNew->token, pToken);
|
||||
}else{
|
||||
pNew->token = *pToken;
|
||||
pNew->flags |= EP_Dequoted;
|
||||
VVA_ONLY( pNew->vvaFlags |= EVVA_ReadOnlyToken; )
|
||||
}
|
||||
}else if( pLeft ){
|
||||
if( pRight ){
|
||||
@@ -660,6 +662,7 @@ void sqlite3ExprDelete(sqlite3 *db, Expr *p){
|
||||
void sqlite3DequoteExpr(sqlite3 *db, Expr *p){
|
||||
if( !ExprHasAnyProperty(p, EP_Dequoted) ){
|
||||
ExprSetProperty(p, EP_Dequoted);
|
||||
assert( (p->vvaFlags & EVVA_ReadOnlyToken)==0 );
|
||||
sqlite3Dequote((char*)p->token.z);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user