Fix infinite loop when writing code at end of file

This resulted in my BBEdit hanging.
This commit is contained in:
Ben S
2015-02-21 13:27:29 +00:00
parent 1154b0df63
commit bfdc57e356

View File

@@ -569,7 +569,7 @@ OSErr calculateRuns(BBLMParamBlock &params, const BBLMCallbackBlock *callbacks)
bool wordchr = false;
while ((ch = iter.GetNextChar()))
{
if (ch == 'r' && iter.strcmp("##\"", 3) == 0)
if (ch == 'r' && iter.CharsLeft() >= 3 && iter.strcmp("##\"", 3) == 0)
{
iter--;
if (!makeCodeRun(iter, runStart, *callbacks)) return noErr;
@@ -675,7 +675,7 @@ OSErr calculateRuns(BBLMParamBlock &params, const BBLMCallbackBlock *callbacks)
iter--;
}
}
else if (ch == 'a' && iter.strcmp("cro_rules!", 10) == 0)
else if (ch == 'a' && iter.CharsLeft() >= 10 && iter.strcmp("cro_rules!", 10) == 0)
{
iter += 10;
ch = iter.GetNextChar();