Exit loop when needed. (Bug 497256) r=roc

This commit is contained in:
L. David Baron 2010-04-06 12:42:41 -07:00
parent 7a20b3b9ab
commit d93e0789b9

View File

@ -6832,7 +6832,8 @@ struct DR_State
PRBool RuleMatches(DR_Rule& aRule,
DR_FrameTreeNode& aNode);
PRBool GetToken(FILE* aFile,
char* aBuf);
char* aBuf,
size_t aBufSize);
DR_Rule* ParseRule(FILE* aFile);
void ParseRulesFile();
void AddRule(nsTArray<DR_Rule*>& aRules,
@ -7025,7 +7026,8 @@ PRBool DR_State::IsWhiteSpace(int c) {
}
PRBool DR_State::GetToken(FILE* aFile,
char* aBuf)
char* aBuf,
size_t aBufSize)
{
PRBool haveToken = PR_FALSE;
aBuf[0] = 0;
@ -7038,8 +7040,9 @@ PRBool DR_State::GetToken(FILE* aFile,
haveToken = PR_TRUE;
aBuf[0] = c;
// get everything up to the next whitespace char
PRInt32 cX;
for (cX = 1, c = getc(aFile); ; cX++, c = getc(aFile)) {
size_t cX;
for (cX = 1; cX + 1 < aBufSize ; cX++) {
c = getc(aFile);
if (c < 0) { // EOF
ungetc(' ', aFile);
break;
@ -7063,7 +7066,7 @@ DR_Rule* DR_State::ParseRule(FILE* aFile)
char buf[128];
PRInt32 doDisplay;
DR_Rule* rule = nsnull;
while (GetToken(aFile, buf)) {
while (GetToken(aFile, buf, sizeof(buf))) {
if (GetNumber(buf, doDisplay)) {
if (rule) {
rule->mDisplay = !!doDisplay;