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

Side by Side Diff: src/utils/SkParsePath.cpp

Issue 1515193002: Fix a crash in SkParsePath::FromSVGString (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add comment Created 5 years 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 | tests/ParsePathTest.cpp » ('j') | 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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "SkParse.h" 8 #include "SkParse.h"
9 #include "SkParsePath.h" 9 #include "SkParsePath.h"
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 bool SkParsePath::FromSVGString(const char data[], SkPath* result) { 70 bool SkParsePath::FromSVGString(const char data[], SkPath* result) {
71 SkPath path; 71 SkPath path;
72 SkPoint f = {0, 0}; 72 SkPoint f = {0, 0};
73 SkPoint c = {0, 0}; 73 SkPoint c = {0, 0};
74 SkPoint lastc = {0, 0}; 74 SkPoint lastc = {0, 0};
75 SkPoint points[3]; 75 SkPoint points[3];
76 char op = '\0'; 76 char op = '\0';
77 char previousOp = '\0'; 77 char previousOp = '\0';
78 bool relative = false; 78 bool relative = false;
79 for (;;) { 79 for (;;) {
80 if (!data) {
81 // Truncated data
82 return false;
83 }
80 data = skip_ws(data); 84 data = skip_ws(data);
81 if (data[0] == '\0') { 85 if (data[0] == '\0') {
82 break; 86 break;
83 } 87 }
84 char ch = data[0]; 88 char ch = data[0];
85 if (is_digit(ch) || ch == '-' || ch == '+') { 89 if (is_digit(ch) || ch == '-' || ch == '+') {
86 if (op == '\0') { 90 if (op == '\0') {
87 return false; 91 return false;
88 } 92 }
89 } else if (is_sep(ch)) { 93 } else if (is_sep(ch)) {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 case SkPath::kClose_Verb: 246 case SkPath::kClose_Verb:
243 stream.write("Z", 1); 247 stream.write("Z", 1);
244 break; 248 break;
245 case SkPath::kDone_Verb: 249 case SkPath::kDone_Verb:
246 str->resize(stream.getOffset()); 250 str->resize(stream.getOffset());
247 stream.copyTo(str->writable_str()); 251 stream.copyTo(str->writable_str());
248 return; 252 return;
249 } 253 }
250 } 254 }
251 } 255 }
OLDNEW
« no previous file with comments | « no previous file | tests/ParsePathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698