Return an error message (instead of segfaulting) if test function fts5_expr() is invoked with no arguments.

FossilOrigin-Name: 8e818b8985c0196cd9671a6491796faaeebeb16e
This commit is contained in:
dan
2015-07-30 11:26:10 +00:00
parent e61d31fa00
commit dbac3ece0f
4 changed files with 25 additions and 10 deletions
+9
View File
@@ -1865,6 +1865,15 @@ static void fts5ExprFunction(
Fts5Config *pConfig = 0;
int iArg = 1;
if( nArg<1 ){
char *zErr = sqlite3_mprintf("wrong number of arguments to function %s",
bTcl ? "fts5_expr_tcl" : "fts5_expr"
);
sqlite3_result_error(pCtx, zErr, -1);
sqlite3_free(zErr);
return;
}
if( bTcl && nArg>1 ){
zNearsetCmd = (const char*)sqlite3_value_text(apVal[1]);
iArg = 2;
+7
View File
@@ -46,6 +46,13 @@ foreach {tn expr res} {
do_execsql_test 1.$tn {SELECT fts5_expr($expr)} [list $res]
}
do_catchsql_test 2.1 {
SELECT fts5_expr()
} {1 {wrong number of arguments to function fts5_expr}}
do_catchsql_test 2.1 {
SELECT fts5_expr_tcl()
} {1 {wrong number of arguments to function fts5_expr_tcl}}
finish_test