Check first deserialized verb of path is a move.
SkPathRef::Iter::next and several other bits of code depend on the first
verb of a path always being a move. Contructors and builders currently
enforce this, so the deserializer must do so also.
BUG=chromium:740789
Change-Id: Iad0f6fc6d2b2fe40064c674fa7dd1612c120bb8f
Reviewed-on: https://skia-review.googlesource.com/22216
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
diff --git a/src/core/SkPathRef.cpp b/src/core/SkPathRef.cpp
index f0fda27..3338225 100644
--- a/src/core/SkPathRef.cpp
+++ b/src/core/SkPathRef.cpp
@@ -190,6 +190,11 @@
// or if an invalid verb is encountered, return false.
static bool deduce_pts_conics(const uint8_t verbs[], int vCount, int* ptCountPtr,
int* conicCountPtr) {
+ // When there is at least one verb, the first is required to be kMove_Verb.
+ if (0 < vCount && verbs[vCount-1] != SkPath::kMove_Verb) {
+ return false;
+ }
+
int ptCount = 0;
int conicCount = 0;
for (int i = 0; i < vCount; ++i) {