}
+// Increment with overflow check.
+// val and delta will both be positive.
+
+static int32_t safeIncrement(int32_t val, int32_t delta) {
+ if (INT32_MAX - val > delta) {
+ return val + delta;
+ } else {
+ return INT32_MAX;
+ }
+}
//------------------------------------------------------------------------------
fRXPat->fInitialChars->add(URX_VAL(op));
numInitialStrings += 2;
}
- currentLen++;
+ currentLen = safeIncrement(currentLen, 1);
atStart = FALSE;
break;
fRXPat->fInitialChars->addAll(*s);
numInitialStrings += 2;
}
- currentLen++;
+ currentLen = safeIncrement(currentLen, 1);
atStart = FALSE;
break;
fRXPat->fInitialChars->addAll(*s);
numInitialStrings += 2;
}
- currentLen++;
+ currentLen = safeIncrement(currentLen, 1);
atStart = FALSE;
break;
fRXPat->fInitialChars->addAll(sc);
numInitialStrings += 2;
}
- currentLen++;
+ currentLen = safeIncrement(currentLen, 1);
atStart = FALSE;
break;
fRXPat->fInitialChars->addAll(s);
numInitialStrings += 2;
}
- currentLen++;
+ currentLen = safeIncrement(currentLen, 1);
atStart = FALSE;
break;
fRXPat->fInitialChars->addAll(s);
numInitialStrings += 2;
}
- currentLen++;
+ currentLen = safeIncrement(currentLen, 1);
atStart = FALSE;
break;
fRXPat->fInitialChars->addAll(s);
numInitialStrings += 2;
}
- currentLen++;
+ currentLen = safeIncrement(currentLen, 1);
atStart = FALSE;
break;
}
numInitialStrings += 2;
}
- currentLen++;
+ currentLen = safeIncrement(currentLen, 1);
atStart = FALSE;
break;
fRXPat->fInitialChars->complement();
numInitialStrings += 2;
}
- currentLen++;
+ currentLen = safeIncrement(currentLen, 1);
atStart = FALSE;
break;
fRXPat->fInitialStringLen = stringLen;
}
- currentLen += stringLen;
+ currentLen = safeIncrement(currentLen, stringLen);
atStart = FALSE;
}
break;
fRXPat->fInitialChars->addAll(s);
numInitialStrings += 2; // Matching on an initial string not possible.
}
- currentLen += stringLen;
+ currentLen = safeIncrement(currentLen, stringLen);
atStart = FALSE;
}
break;
case URX_DOTANY_ALL: // . matches one or two.
case URX_DOTANY:
case URX_DOTANY_UNIX:
- currentLen++;
+ currentLen = safeIncrement(currentLen, 1);
break;
{
loc++;
int32_t stringLenOp = (int32_t)fRXPat->fCompiledPat->elementAti(loc);
- currentLen += URX_VAL(stringLenOp);
+ currentLen = safeIncrement(currentLen, URX_VAL(stringLenOp));
}
break;
// Assume a min length of one for now. A min length of zero causes
// optimization failures for a pattern like "string"+
// currentLen += URX_VAL(stringLenOp);
- currentLen += 1;
+ currentLen = safeIncrement(currentLen, 1);
}
break;
return currentLen;
}
-// Increment with overflow check.
-// val and delta will both be positive.
-
-static int32_t safeIncrement(int32_t val, int32_t delta) {
- if (INT32_MAX - val > delta) {
- return val + delta;
- } else {
- return INT32_MAX;
- }
-}
-
-
//------------------------------------------------------------------------------
//
// maxMatchLength Calculate the length of the longest string that could