[Pkg-javascript-commits] [uglifyjs] 137/190: Prevent endless recursion when evaluating self-referencing consts
Antonio Terceiro
terceiro at moszumanska.debian.org
Sun Aug 7 23:17:20 UTC 2016
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to annotated tag upstream/2.7.0
in repository uglifyjs.
commit 4b4528ee0552edb7ba1d24dad89e29880065e1c0
Author: Richard van Velzen <rvanvelzen at experty.com>
Date: Tue Apr 12 20:30:44 2016 +0200
Prevent endless recursion when evaluating self-referencing consts
Fix #1041
---
lib/compress.js | 12 ++++++++++--
test/compress/issue-1041.js | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/lib/compress.js b/lib/compress.js
index 153e70f..3e33c1b 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1030,8 +1030,16 @@ merge(Compressor.prototype, {
: ev(this.alternative, compressor);
});
def(AST_SymbolRef, function(compressor){
- var d = this.definition();
- if (d && d.constant && d.init) return ev(d.init, compressor);
+ if (this._evaluating) throw def;
+ this._evaluating = true;
+ try {
+ var d = this.definition();
+ if (d && d.constant && d.init) {
+ return ev(d.init, compressor);
+ }
+ } finally {
+ this._evaluating = false;
+ }
throw def;
});
def(AST_Dot, function(compressor){
diff --git a/test/compress/issue-1041.js b/test/compress/issue-1041.js
new file mode 100644
index 0000000..9dd176f
--- /dev/null
+++ b/test/compress/issue-1041.js
@@ -0,0 +1,39 @@
+const_declaration: {
+ options = {
+ evaluate: true
+ };
+
+ input: {
+ const goog = goog || {};
+ }
+ expect: {
+ const goog = goog || {};
+ }
+}
+
+const_pragma: {
+ options = {
+ evaluate: true
+ };
+
+ input: {
+ /** @const */ var goog = goog || {};
+ }
+ expect: {
+ var goog = goog || {};
+ }
+}
+
+// for completeness' sake
+not_const: {
+ options = {
+ evaluate: true
+ };
+
+ input: {
+ var goog = goog || {};
+ }
+ expect: {
+ var goog = goog || {};
+ }
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git
More information about the Pkg-javascript-commits
mailing list