Make memcmps in GrResourceKey::op== safe.
Previously the size of one of the keys was passed to memcmp. It was incorrectly assumed that if the size mismatched in the first word compared then the rest of the keys would not be accessed. Change-Id: I9850949c6b51d0d2fb6de53ed8d4dee5192826d2 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280356 Commit-Queue: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com> Auto-Submit: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
713ac8a9fc
commit
34ed73b038
@ -49,9 +49,10 @@ protected:
|
||||
}
|
||||
|
||||
bool operator==(const GrResourceKey& that) const {
|
||||
return this->hash() == that.hash() && 0 == memcmp(&fKey[kHash_MetaDataIdx + 1],
|
||||
&that.fKey[kHash_MetaDataIdx + 1],
|
||||
this->internalSize() - sizeof(uint32_t));
|
||||
// Both keys should be sized to at least contain the meta data. The metadata contains each
|
||||
// key's length. So the second memcmp should only run if the keys have the same length.
|
||||
return 0 == memcmp(fKey.get(), that.fKey.get(), kMetaDataCnt*sizeof(uint32_t)) &&
|
||||
0 == memcmp(&fKey[kMetaDataCnt], &that.fKey[kMetaDataCnt], this->dataSize());
|
||||
}
|
||||
|
||||
GrResourceKey& operator=(const GrResourceKey& that) {
|
||||
|
Loading…
Reference in New Issue
Block a user