Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(621)

Side by Side Diff: src/sksl/SkSLParser.cpp

Issue 2420163002: another SkSL crash fix (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "stdio.h" 8 #include "stdio.h"
9 #include "SkSLParser.h" 9 #include "SkSLParser.h"
10 #include "SkSLToken.h" 10 #include "SkSLToken.h"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 } 324 }
325 std::vector<Type::Field> fields; 325 std::vector<Type::Field> fields;
326 while (this->peek().fKind != Token::RBRACE) { 326 while (this->peek().fKind != Token::RBRACE) {
327 std::unique_ptr<ASTVarDeclarations> decl = this->varDeclarations(); 327 std::unique_ptr<ASTVarDeclarations> decl = this->varDeclarations();
328 if (!decl) { 328 if (!decl) {
329 return nullptr; 329 return nullptr;
330 } 330 }
331 for (const auto& var : decl->fVars) { 331 for (const auto& var : decl->fVars) {
332 auto type = (const Type*) fTypes[decl->fType->fName]; 332 auto type = (const Type*) fTypes[decl->fType->fName];
333 for (int i = (int) var.fSizes.size() - 1; i >= 0; i--) { 333 for (int i = (int) var.fSizes.size() - 1; i >= 0; i--) {
334 if (var.fSizes[i]->fKind != ASTExpression::kInt_Kind) { 334 if (!var.fSizes[i] || var.fSizes[i]->fKind != ASTExpression::kIn t_Kind) {
335 this->error(decl->fPosition, "array size in struct field mus t be a constant"); 335 this->error(decl->fPosition, "array size in struct field mus t be a constant");
336 return nullptr;
336 } 337 }
337 uint64_t columns = ((ASTIntLiteral&) *var.fSizes[i]).fValue; 338 uint64_t columns = ((ASTIntLiteral&) *var.fSizes[i]).fValue;
338 std::string name = type->name() + "[" + to_string(columns) + "]" ; 339 std::string name = type->name() + "[" + to_string(columns) + "]" ;
339 type = new Type(name, Type::kArray_Kind, *type, (int) columns); 340 type = new Type(name, Type::kArray_Kind, *type, (int) columns);
340 fTypes.takeOwnership((Type*) type); 341 fTypes.takeOwnership((Type*) type);
341 } 342 }
342 fields.push_back(Type::Field(decl->fModifiers, var.fName, type)); 343 fields.push_back(Type::Field(decl->fModifiers, var.fName, type));
343 if (var.fValue) { 344 if (var.fValue) {
344 this->error(decl->fPosition, "initializers are not permitted on struct fields"); 345 this->error(decl->fPosition, "initializers are not permitted on struct fields");
345 } 346 }
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 bool Parser::identifier(std::string* dest) { 1445 bool Parser::identifier(std::string* dest) {
1445 Token t; 1446 Token t;
1446 if (this->expect(Token::IDENTIFIER, "identifier", &t)) { 1447 if (this->expect(Token::IDENTIFIER, "identifier", &t)) {
1447 *dest = t.fText; 1448 *dest = t.fText;
1448 return true; 1449 return true;
1449 } 1450 }
1450 return false; 1451 return false;
1451 } 1452 }
1452 1453
1453 } // namespace 1454 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698