static analyzer warning fix

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-06-12 22:59:15 +03:00
parent e5710f5067
commit 341ed426a7

View file

@ -108,9 +108,12 @@ void RegExp::compile()
int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector) int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
{ {
if (startOffset < 0) if (!ovector) {
return -1;
}
if (startOffset < 0) {
startOffset = 0; startOffset = 0;
if (ovector) }
ovector->clear(); ovector->clear();
if (startOffset > s.size() || s.isNull()) if (startOffset > s.size() || s.isNull())
@ -124,8 +127,6 @@ int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
#ifndef QT_NO_DEBUG #ifndef QT_NO_DEBUG
fprintf(stderr, "jsRegExpExecute failed with result\n"); fprintf(stderr, "jsRegExpExecute failed with result\n");
#endif #endif
if (ovector)
ovector->clear();
return -1; return -1;
} }
@ -133,17 +134,8 @@ int RegExp::match(const UString& s, int startOffset, Vector<int, 32>* ovector)
// Set up the offset vector for the result. // Set up the offset vector for the result.
// First 2/3 used for result, the last third unused but there for compatibility. // First 2/3 used for result, the last third unused but there for compatibility.
int* offsetVector; ovector->resize((capsize + 1) * 3);
int offsetVectorSize; int* offsetVector= ovector->data();
int fixedSizeOffsetVector[3];
if (!ovector) {
offsetVectorSize = 3;
offsetVector = fixedSizeOffsetVector;
} else {
offsetVectorSize = (capsize + 1) * 3;
ovector->resize(offsetVectorSize);
offsetVector = ovector->data();
}
size_t nummatches = 0; size_t nummatches = 0;
for (int i = 0; i < capsize; i++) { for (int i = 0; i < capsize; i++) {