Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fix #382 leak of json in local/remote schema (valgrind)
- Loading branch information
Showing
with
12 additions
and
1 deletion.
-
+6
−1
src/searchd.cpp
-
+5
−0
src/sphinx.cpp
-
+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 |
|
|