Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix possible crash in PAL labeling engine due to incorrect size initi…
…alization of vector

If the number of candidates is < the number of features (i.e. some features have
no candidates), we'll get a crash. And if the number of candidates >> number of features
(the usual case), we're just creating a much larger vector than we'll ever use...

(I think. It's pal. No-one know for sure.)
  • Loading branch information
nyalldawson committed Nov 28, 2019
1 parent d89745a commit 1788e2e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/pal/problem.cpp
Expand Up @@ -218,7 +218,7 @@ void Problem::init_sol_falp()
int label;
PriorityQueue *list = nullptr;

mSol.init( mTotalCandidates );
mSol.init( mFeatureCount );

list = new PriorityQueue( mTotalCandidates, mAllNblp, true );

Expand Down
2 changes: 1 addition & 1 deletion src/core/pal/problem.h
Expand Up @@ -197,7 +197,7 @@ namespace pal

double totalCost = 0;

void init( int featureCount )
void init( std::size_t featureCount )
{
activeLabelIds.resize( featureCount, -1 );
totalCost = 0;
Expand Down

0 comments on commit 1788e2e

Please sign in to comment.