Limit max iterations for tighten_body
authorMihai Bazon <mihai.bazon@gmail.com>
Mon, 16 Nov 2015 10:06:12 +0000 (12:06 +0200)
committerMihai Bazon <mihai.bazon@gmail.com>
Mon, 16 Nov 2015 10:08:24 +0000 (12:08 +0200)
Ref #866

lib/compress.js

index 3efca41..c384e99 100644 (file)
@@ -199,7 +199,7 @@ merge(Compressor.prototype, {
     };
 
     function tighten_body(statements, compressor) {
-        var CHANGED;
+        var CHANGED, max_iter = 10;
         do {
             CHANGED = false;
             if (compressor.option("angular")) {
@@ -218,7 +218,7 @@ merge(Compressor.prototype, {
             if (compressor.option("join_vars")) {
                 statements = join_consecutive_vars(statements, compressor);
             }
-        } while (CHANGED);
+        } while (CHANGED && max_iter-- > 0);
 
         if (compressor.option("negate_iife")) {
             negate_iifes(statements, compressor);