From bfdc57e35622908caf7b648805a845bb0d234a6d Mon Sep 17 00:00:00 2001 From: Ben S Date: Sat, 21 Feb 2015 13:27:29 +0000 Subject: [PATCH] Fix infinite loop when writing code at end of file This resulted in my BBEdit hanging. --- rust.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust.mm b/rust.mm index a89caae..48201a1 100644 --- a/rust.mm +++ b/rust.mm @@ -569,7 +569,7 @@ OSErr calculateRuns(BBLMParamBlock ¶ms, 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 ¶ms, 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();