Permalink
Browse files

Fix #382 leak of json in local/remote schema (valgrind)

  • Loading branch information...
klirichek committed Aug 8, 2018
1 parent 0193946 commit 943e2997b33f9b2eda23d94a66068910f9476ebd
Showing with 12 additions and 1 deletion.
  1. +6 −1 src/searchd.cpp
  2. +5 −0 src/sphinx.cpp
  3. +1 −0 src/sphinx.h
@@ -5232,12 +5232,16 @@ void RemapResult ( const ISphSchema * pTarget, AggrResult_t * pRes )
CSphSchema & dSchema = pRes->m_dSchemas[iSchema];
for ( int i=0; i<pTarget->GetAttrsCount(); i++ )
{
dMapFrom.Add ( dSchema.GetAttrIndex ( pTarget->GetAttr(i).m_sName.cstr() ) );
auto iSrcCol = dSchema.GetAttrIndex ( pTarget->GetAttr ( i ).m_sName.cstr () );
const CSphColumnInfo &tSrcCol = dSchema.GetAttr ( iSrcCol );
dMapFrom.Add ( iSrcCol );
assert ( dMapFrom[i]>=0
|| pTarget->GetAttr(i).m_tLocator.IsID()
|| sphIsSortStringInternal ( pTarget->GetAttr(i).m_sName.cstr() )
|| pTarget->GetAttr(i).m_sName=="@groupbystr"
);
int iOffset = tSrcCol.m_tLocator.m_iBitOffset / ( 8 * sizeof ( CSphRowitem ) );
dSchema.DiscardPtr ( iOffset );
}
int iLimit = Min ( iCur + pRes->m_dMatchCounts[iSchema], pRes->m_dMatches.GetLength() );
for ( int i=iCur; i<iLimit; i++ )
@@ -5275,6 +5279,7 @@ void RemapResult ( const ISphSchema * pTarget, AggrResult_t * pRes )
}
// swap out old (most likely wrong sized) match
Swap ( tMatch, tRow );
dSchema.FreeDataPtrs ( &tRow );
}
iCur = iLimit;
@@ -6034,6 +6034,11 @@ void CSphSchemaHelper::FreeDataPtrs ( CSphMatch * pMatch ) const
}
}
void CSphSchemaHelper::DiscardPtr ( int iAttr )
{
m_dDataPtrAttrs.RemoveValue ( iAttr );
}
void CSphSchemaHelper::CloneMatch ( CSphMatch * pDst, const CSphMatch & rhs ) const
{
@@ -1567,6 +1567,7 @@ class CSphSchemaHelper : public ISphSchema
public:
virtual void FreeDataPtrs ( CSphMatch * pMatch ) const;
virtual void CloneMatch ( CSphMatch * pDst, const CSphMatch & rhs ) const;
void DiscardPtr ( int iAttr );
protected:
CSphVector<int> m_dDataPtrAttrs; // rowitems of pointers to data that are stored inside matches

0 comments on commit 943e299

Please sign in to comment.