mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-23 11:22:09 +03:00
Fix a segfault in fts3 that may occur if the snippet, offsets or matchinfo functions are used in a query that does not contain a MATCH clause.
FossilOrigin-Name: 14ab536a96f81595ab8c3dcd4b72075f1a827c8b
This commit is contained in:
@ -926,6 +926,11 @@ void sqlite3Fts3Snippet(
|
||||
SnippetFragment aSnippet[4]; /* Maximum of 4 fragments per snippet */
|
||||
int nFToken = -1; /* Number of tokens in each fragment */
|
||||
|
||||
if( !pCsr->pExpr ){
|
||||
sqlite3_result_text(pCtx, "", 0, SQLITE_STATIC);
|
||||
return;
|
||||
}
|
||||
|
||||
for(nSnippet=1; 1; nSnippet++){
|
||||
|
||||
int iSnip; /* Loop counter 0..nSnippet-1 */
|
||||
@ -1053,6 +1058,11 @@ void sqlite3Fts3Offsets(
|
||||
StrBuffer res = {0, 0, 0}; /* Result string */
|
||||
TermOffsetCtx sCtx; /* Context for fts3ExprTermOffsetInit() */
|
||||
|
||||
if( !pCsr->pExpr ){
|
||||
sqlite3_result_text(pCtx, "", 0, SQLITE_STATIC);
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&sCtx, 0, sizeof(sCtx));
|
||||
assert( pCsr->isRequireSeek==0 );
|
||||
|
||||
@ -1168,7 +1178,12 @@ void sqlite3Fts3Offsets(
|
||||
** Implementation of matchinfo() function.
|
||||
*/
|
||||
void sqlite3Fts3Matchinfo(sqlite3_context *pContext, Fts3Cursor *pCsr){
|
||||
int rc = fts3GetMatchinfo(pCsr);
|
||||
int rc;
|
||||
if( !pCsr->pExpr ){
|
||||
sqlite3_result_blob(pContext, "", 0, SQLITE_STATIC);
|
||||
return;
|
||||
}
|
||||
rc = fts3GetMatchinfo(pCsr);
|
||||
if( rc!=SQLITE_OK ){
|
||||
sqlite3_result_error_code(pContext, rc);
|
||||
}else{
|
||||
|
Reference in New Issue
Block a user