Fix leak in SkReadBuffer::readFlattenable.

If an object did not have the expected type, we would return null, but
leak the undesired object.

Change-Id: I4f799e6583f8d35e852319106b5b07a5a2e4d354
Bug: oss-fuzz:45240, oss-fuzz:45256, oss-fuzz:45265, oss-fuzz:45270
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/516797
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
John Stiles 2022-03-07 07:59:27 -05:00 committed by SkCQ
parent 8e6f4d08ce
commit c8cb357b53

View File

@ -464,6 +464,7 @@ SkFlattenable* SkReadBuffer::readFlattenable(SkFlattenable::Type ft) {
SkFlattenable* obj = this->readRawFlattenable();
if (obj && obj->getFlattenableType() != ft) {
this->validate(false);
delete obj;
return nullptr;
}
return obj;