Skip to content

Commit

Permalink
Fix crash on strcmp invalid use
Browse files Browse the repository at this point in the history
That should most probably fix github #395
  • Loading branch information
klirichek committed Aug 19, 2020
1 parent b6beb3b commit 59d94ce
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/sphinx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9298,6 +9298,15 @@ void CSphHitBuilder::DoclistEndList ()
m_dSkiplist.Resize ( 0 );
}

static int strcmpp (const char* l, const char* r)
{
const char* szEmpty = "";
if ( !l )
l = szEmpty;
if ( !r )
r = szEmpty;
return strcmp ( l, r );
}

void CSphHitBuilder::cidxHit ( CSphAggregateHit * pHit )
{
Expand All @@ -9309,7 +9318,7 @@ void CSphHitBuilder::cidxHit ( CSphAggregateHit * pHit )
// next word
/////////////

const bool bNextWord = ( m_tLastHit.m_uWordID!=pHit->m_uWordID || ( m_pDict->GetSettings().m_bWordDict && strcmp ( (char*)m_tLastHit.m_sKeyword, (char*)pHit->m_sKeyword ) ) ); // OPTIMIZE?
const bool bNextWord = ( m_tLastHit.m_uWordID!=pHit->m_uWordID || ( m_pDict->GetSettings().m_bWordDict && strcmpp ( (char*)m_tLastHit.m_sKeyword, (char*)pHit->m_sKeyword ) ) ); // OPTIMIZE?
const bool bNextDoc = bNextWord || ( m_tLastHit.m_tRowID!=pHit->m_tRowID );

if ( m_bGotFieldEnd && ( bNextWord || bNextDoc ) )
Expand Down

0 comments on commit 59d94ce

Please sign in to comment.