Title: [196925] releases/WebKitGTK/webkit-2.10/Source/_javascript_Core
Revision
196925
Author
[email protected]
Date
2016-02-22 02:29:05 -0800 (Mon, 22 Feb 2016)

Log Message

Merge r196587 - Parser::parseVariableDeclarationList should null check the node before attempting to create a new CommaExpr
https://bugs.webkit.org/show_bug.cgi?id=154244
rdar://problem/24290670

Reviewed by Michael Saboff.

* parser/ASTBuilder.h:
(JSC::ASTBuilder::appendToCommaExpr): Catch the bug sooner in debug.
* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseVariableDeclarationList): Fix the bug.
* tests/stress/for-let-comma.js: Added. This used to crash in debug and release.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/ChangeLog (196924 => 196925)


--- releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/ChangeLog	2016-02-22 10:22:50 UTC (rev 196924)
+++ releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/ChangeLog	2016-02-22 10:29:05 UTC (rev 196925)
@@ -1,3 +1,17 @@
+2016-02-15  Filip Pizlo  <[email protected]>
+
+        Parser::parseVariableDeclarationList should null check the node before attempting to create a new CommaExpr
+        https://bugs.webkit.org/show_bug.cgi?id=154244
+        rdar://problem/24290670
+
+        Reviewed by Michael Saboff.
+
+        * parser/ASTBuilder.h:
+        (JSC::ASTBuilder::appendToCommaExpr): Catch the bug sooner in debug.
+        * parser/Parser.cpp:
+        (JSC::Parser<LexerType>::parseVariableDeclarationList): Fix the bug.
+        * tests/stress/for-let-comma.js: Added. This used to crash in debug and release.
+
 2016-02-09  Filip Pizlo  <[email protected]>
 
         Don't crash if we fail to parse a builtin

Modified: releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/parser/ASTBuilder.h (196924 => 196925)


--- releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/parser/ASTBuilder.h	2016-02-22 10:22:50 UTC (rev 196924)
+++ releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/parser/ASTBuilder.h	2016-02-22 10:29:05 UTC (rev 196925)
@@ -692,6 +692,7 @@
     CommaNode* appendToCommaExpr(const JSTokenLocation& location, ExpressionNode*, ExpressionNode* tail, ExpressionNode* next)
     {
         ASSERT(tail->isCommaNode());
+        ASSERT(next);
         CommaNode* newTail = new (m_parserArena) CommaNode(location, next);
         static_cast<CommaNode*>(tail)->setNext(newTail);
         return newTail;

Modified: releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/parser/Parser.cpp (196924 => 196925)


--- releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/parser/Parser.cpp	2016-02-22 10:22:50 UTC (rev 196924)
+++ releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/parser/Parser.cpp	2016-02-22 10:29:05 UTC (rev 196925)
@@ -647,14 +647,16 @@
                 lastInitializer = rhs;
             }
         }
-        
-        if (!head)
-            head = node;
-        else if (!tail) {
-            head = context.createCommaExpr(location, head);
-            tail = context.appendToCommaExpr(location, head, head, node);
-        } else
-            tail = context.appendToCommaExpr(location, head, tail, node);
+
+        if (node) {
+            if (!head)
+                head = node;
+            else if (!tail) {
+                head = context.createCommaExpr(location, head);
+                tail = context.appendToCommaExpr(location, head, head, node);
+            } else
+                tail = context.appendToCommaExpr(location, head, tail, node);
+        }
     } while (match(COMMA));
     if (lastIdent)
         lastPattern = context.createBindingLocation(lastIdentToken.m_location, *lastIdent, lastIdentToken.m_startPosition, lastIdentToken.m_endPosition, assignmentContext);

Added: releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/tests/stress/for-let-comma.js (0 => 196925)


--- releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/tests/stress/for-let-comma.js	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.10/Source/_javascript_Core/tests/stress/for-let-comma.js	2016-02-22 10:29:05 UTC (rev 196925)
@@ -0,0 +1,16 @@
+function foo() {
+    var array = [];
+    for (let x = 0, []; x < 10; ++x) { array.push(x); }
+    return array;
+}
+
+var result = foo();
+if (result.length != 10)
+    throw "Error: bad length: " + result.length;
+for (var i = 0; i < 10; ++i) {
+    if (result[i] != i)
+        throw "Error: bad entry at i = " + i + ": " + result[i];
+}
+if (result.length != 10)
+    throw "Error: bad length: " + result.length;
+
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to