Skip to content
Permalink
Browse files

Fix #413, leakage of dynamic strings on early rejected matches.

Example of the query affected by leak:
select gid a, to_string(a) b from test where match('title') and b='';

(cherry picked from commit 13eb03877f78dfc0bb7923cfde3f114d9bfe598f)
  • Loading branch information
klirichek committed Aug 23, 2018
1 parent 9154b18 commit 7c138f15ca23c0c8717fa12041e3db7f988fcf15
Showing with 12 additions and 3 deletions.
  1. +12 −3 src/sphinx.cpp
@@ -14436,9 +14436,18 @@ bool CSphIndex_VLN::EarlyReject ( CSphQueryContext * pCtx, CSphMatch & tMatch )
}
CopyDocinfo ( pCtx, tMatch, pRow );
}
pCtx->CalcFilter ( tMatch ); // FIXME!!! leak of filtered STRING_PTR

return pCtx->m_pFilter ? !pCtx->m_pFilter->Eval ( tMatch ) : false;
pCtx->CalcFilter ( tMatch );
if ( !pCtx->m_pFilter )
return false;

if ( !pCtx->m_pFilter->Eval ( tMatch ) )
{
pCtx->FreeDataFilter ( tMatch );
return true;
}

return false;
}

SphDocID_t * CSphIndex_VLN::GetKillList () const
@@ -14632,7 +14641,7 @@ static inline void CalcContextItems ( CSphMatch & tMatch, const CSphVector<CSphQ
break;

case SPH_ATTR_STRINGPTR:
tMatch.SetAttr ( tCalc.m_tLoc, (SphAttr_t)tCalc.m_pExpr->StringEvalPacked ( tMatch ) ); // FIXME! a potential leak of *previous* value?
tMatch.SetAttr ( tCalc.m_tLoc, (SphAttr_t)tCalc.m_pExpr->StringEvalPacked ( tMatch ) );
break;

case SPH_ATTR_FACTORS:

0 comments on commit 7c138f1

Please sign in to comment.
You can’t perform that action at this time.