[Pkg-javascript-commits] [uglifyjs] 55/228: fix crash on missing `props` to `string_template()` (#1523)

Jonas Smedegaard dr at jones.dk
Sat Apr 15 14:25:16 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository uglifyjs.

commit c2334baa4813bdde21d5a652de0c9da3733d06b6
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date:   Wed Mar 1 15:25:26 2017 +0800

    fix crash on missing `props` to `string_template()` (#1523)
    
    Patched up `make_node()` without `orig`.
    
    There may be other cases where `start` could be missing, so make it print "undefined" instead of crashing.
    
    fixes #1518
---
 lib/compress.js | 6 +++---
 lib/utils.js    | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/compress.js b/lib/compress.js
index b9ad8e9..32e7a64 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -2194,7 +2194,7 @@ merge(Compressor.prototype, {
             // here because they are only used in an equality comparison later on.
             self.condition = negated;
             var tmp = self.body;
-            self.body = self.alternative || make_node(AST_EmptyStatement);
+            self.body = self.alternative || make_node(AST_EmptyStatement, self);
             self.alternative = tmp;
         }
         if (is_empty(self.body) && is_empty(self.alternative)) {
@@ -2459,7 +2459,7 @@ merge(Compressor.prototype, {
                   case "Boolean":
                     if (self.args.length == 0) return make_node(AST_False, self);
                     if (self.args.length == 1) return make_node(AST_UnaryPrefix, self, {
-                        expression: make_node(AST_UnaryPrefix, null, {
+                        expression: make_node(AST_UnaryPrefix, self, {
                             expression: self.args[0],
                             operator: "!"
                         }),
@@ -2855,7 +2855,7 @@ merge(Compressor.prototype, {
                 compressor.warn("Boolean && always false [{file}:{line},{col}]", self.start);
                 return make_node(AST_Seq, self, {
                     car: self.left,
-                    cdr: make_node(AST_False)
+                    cdr: make_node(AST_False, self)
                 }).optimize(compressor);
             }
             if (ll.length > 1 && ll[1]) {
diff --git a/lib/utils.js b/lib/utils.js
index 46adfd4..da66354 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -185,7 +185,7 @@ function push_uniq(array, el) {
 
 function string_template(text, props) {
     return text.replace(/\{(.+?)\}/g, function(str, p){
-        return props[p];
+        return props && props[p];
     });
 };
 

-- 
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