Add missing check for too many language hints
git-svn-id: https://cld2.googlecode.com/svn/trunk@11 b252ecd4-b096-bf77-eb8e-91563289f87e
This commit is contained in:
@@ -949,7 +949,8 @@ void MergeCLDLangPriorsMax(OneCLDLangPrior olp, CLDLangPriors* lps) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Not found; add it
|
// Not found; add it if room
|
||||||
|
if (lps->n >= kMaxOneCLDLangPrior) {return;}
|
||||||
lps->prior[lps->n++] = olp;
|
lps->prior[lps->n++] = olp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -964,7 +965,8 @@ void MergeCLDLangPriorsBoost(OneCLDLangPrior olp, CLDLangPriors* lps) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Not found; add it
|
// Not found; add it if room
|
||||||
|
if (lps->n >= kMaxOneCLDLangPrior) {return;}
|
||||||
lps->prior[lps->n++] = olp;
|
lps->prior[lps->n++] = olp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,9 +31,10 @@ namespace CLD2 {
|
|||||||
// Full language in bottom 10 bits, weight in top 6 bits
|
// Full language in bottom 10 bits, weight in top 6 bits
|
||||||
typedef int16 OneCLDLangPrior;
|
typedef int16 OneCLDLangPrior;
|
||||||
|
|
||||||
|
const int kMaxOneCLDLangPrior = 14;
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32 n;
|
int32 n;
|
||||||
OneCLDLangPrior prior[14];
|
OneCLDLangPrior prior[kMaxOneCLDLangPrior];
|
||||||
} CLDLangPriors;
|
} CLDLangPriors;
|
||||||
|
|
||||||
// Reading exposed here; setting hidden in .cc
|
// Reading exposed here; setting hidden in .cc
|
||||||
|
Reference in New Issue
Block a user