terinjokes/gulp-uglify

Infinite Loop

Closed this issue · 1 comments

I got this Javascript:

function abc() {
  var s = "Test";
  s = ['<tpl>', s, '</tpl>'].join('');

  var re = /<tpl>.*<\/tpl>/;
  var m, id = 0;

  while(m = s.match(re)){
    s = s.replace(m[0], '{xtpl'+ id + '}');
    ++id;
  }
};

This javascript is reduced to:

function abc(){for(var t,l="Test",p=/<tpl>.*<\/tpl>/,a=0;t=(l=["<tpl>",l,"</tpl>"].join("")).match(p);)l=l.replace(t[0],"{xtpl"+a+"}"),++a}

This results in an endlos loop because variable "l" because it is used in the for condition

Thanks for the report - next time please file them in https://github.com/mishoo/UglifyJS2/issues instead.

Fix is pending at mishoo/UglifyJS#3139