Skip to content

Commit 1c372d4

Browse files
committed
fix
1 parent c77e8dd commit 1c372d4

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

src/sorterscroll.cpp

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class ScrollSorter_T : public ISphMatchSorter
6464
CSphVector<CSphRowitem> m_dStatic;
6565
CSphMatchComparatorState m_tState;
6666
ScrollSettings_t m_tScroll;
67-
CSphVector<const CSphColumnInfo*> m_dAllocatedPtrAttrs; // Track which attributes we allocated pointers for
67+
CSphVector<BYTE*> m_dAllocatedPtrs; // Track allocated pointer values directly
6868

6969
FORCE_INLINE bool PushMatch ( const CSphMatch & tEntry );
7070
void SetupRefMatch();
@@ -161,9 +161,10 @@ void ScrollSorter_T<COMP>::SetupRefMatch()
161161
// After remapping, pAttr should be SPH_ATTR_STRINGPTR, but check to be safe
162162
if ( pAttr->m_eAttrType==SPH_ATTR_STRINGPTR )
163163
{
164-
sphSetRowAttr ( pRowData, pAttr->m_tLocator, (SphAttr_t)sphPackPtrAttr ( { (const BYTE*)i.m_sValue.cstr(), i.m_sValue.Length() } ) );
165-
// Track that we allocated a pointer for this attribute
166-
m_dAllocatedPtrAttrs.Add(pAttr);
164+
BYTE * pPacked = sphPackPtrAttr ( { (const BYTE*)i.m_sValue.cstr(), i.m_sValue.Length() } );
165+
sphSetRowAttr ( pRowData, pAttr->m_tLocator, (SphAttr_t)pPacked );
166+
// Track the allocated pointer value directly
167+
m_dAllocatedPtrs.Add(pPacked);
167168
}
168169
break;
169170

@@ -181,26 +182,16 @@ void ScrollSorter_T<COMP>::SetupRefMatch()
181182
template <typename COMP>
182183
void ScrollSorter_T<COMP>::FreeDataPtrAttrs()
183184
{
184-
if ( !m_tRefMatch.m_pDynamic && !m_tRefMatch.m_pStatic )
185-
return;
186-
187-
// Only free pointers for attributes that we actually allocated
188-
for ( auto pAttr : m_dAllocatedPtrAttrs )
185+
// Free all pointers we allocated directly
186+
// We store the pointer values themselves, not the attributes, so we don't need
187+
// to access m_tRefMatch which might have been reset
188+
for ( auto pPacked : m_dAllocatedPtrs )
189189
{
190-
if ( !pAttr )
191-
continue;
192-
193-
if ( pAttr->m_tLocator.m_bDynamic && !m_tRefMatch.m_pDynamic )
194-
continue;
195-
if ( !pAttr->m_tLocator.m_bDynamic && !m_tRefMatch.m_pStatic )
196-
continue;
197-
198-
auto pData = (BYTE *)m_tRefMatch.GetAttr ( pAttr->m_tLocator );
199-
if ( pData )
200-
sphDeallocatePacked(pData);
190+
if ( pPacked )
191+
sphDeallocatePacked(pPacked);
201192
}
202193

203-
m_dAllocatedPtrAttrs.Resize(0);
194+
m_dAllocatedPtrs.Resize(0);
204195
}
205196

206197
/////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)