From 6248b05d0e7acd9954adee008aab302e10835941 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sun, 16 Apr 2006 00:37:57 +0000 Subject: [PATCH] Peephole optimization for infinite loop protection code. git-svn-id: http://htmlpurifier.org/svnroot/html_purifier/trunk@29 48356398-32a2-884e-a903-53898d9a118a --- HTML_Lexer.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/HTML_Lexer.php b/HTML_Lexer.php index 53dfc771..cad7d4cf 100644 --- a/HTML_Lexer.php +++ b/HTML_Lexer.php @@ -62,8 +62,7 @@ class HTML_Lexer while(true) { // infinite loop protection - $loops++; - if ($loops > 200000) return array(); + if (++$loops > 200000) return array(); $position_next_lt = strpos($string, '<', $cursor); $position_next_gt = strpos($string, '>', $cursor); @@ -173,8 +172,7 @@ class HTML_Lexer // infinite loop protection // if we've looped 1000 times, abort. Nothing good can come of this - $loops++; - if ($loops > 1000) return array(); + if (++$loops > 1000) return array(); if ($cursor >= $size) { break;