[skottie] More defensive array indexing

Rapidjson's array [] operator asserts the index is valid (instead of
returning a null value when out-of-range) -> we must check.

Bug: skia:7918
Change-Id: Ice4a6e6670a824da0d423da4a6f92414cd0dc252
Reviewed-on: https://skia-review.googlesource.com/126441
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
This commit is contained in:
Florin Malita 2018-05-07 10:02:13 -04:00 committed by Skia Commit-Bot
parent c3b0822d50
commit 0ca7a88e64

View File

@ -170,7 +170,7 @@ size_t ValueRef::size() const {
}
ValueRef ValueRef::operator[](size_t i) const {
return this->isArray() ? ValueRef(fValue->operator[](i)) : ValueRef();
return i < this->size() ? ValueRef(fValue->operator[](i)) : ValueRef();
}
ValueRef ValueRef::operator[](const char* key) const {