OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |