QTriangulator: make a primeForCount() precondition explicit
Coverity complains that the binary search algorithm can yield high = 32, which, when passed to primeForNumBits(), will overflow prime_deltas[]. This is true, for negative 'count', or, more general, if the MSB of 'count' is set. Add a Q_ASSERT(count >= 0) to inform Coverity (and other readers of the code) that this function is only expecting non-negative arguments. Amends 4adf5e1a9ef4fe78f4b70b7462943246903f4f11, which didn't fully solve the issue, at least not as far as Coverity is concerned. Pick-to: 6.8 6.5 Coverity-Id: 11295 Task-number: QTBUG-134543 Change-Id: I994dd1d1850c6644188a9fc0b83973614dd51e6b Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> (cherry picked from commit 536cd1ce20a59e4daaf3a09c115f2dc5ad9cbf91) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
4ac20b3e5a
commit
af6a417acb
@ -418,6 +418,7 @@ static inline int primeForNumBits(int numBits)
|
||||
|
||||
static inline int primeForCount(int count)
|
||||
{
|
||||
Q_ASSERT(count >= 0); // Q_PRE
|
||||
int low = 0;
|
||||
int high = 32;
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user