Don't pass null to memcmp.
This will allow us to add nonnull-attribute to the UBSAN bot. We are in fact hitting a case where one of the arguments is null and the other not, which seems dicey. I think the scenario is comparing the empty pathref with another path ref that's just been COWed, without any verbs or points yet. BUG=skia: Review URL: https://codereview.chromium.org/732643002
This commit is contained in:
parent
36e6e266b8
commit
d4897591fd
@ -193,12 +193,18 @@ bool SkPathRef::operator== (const SkPathRef& ref) const {
|
||||
SkASSERT(!genIDMatch);
|
||||
return false;
|
||||
}
|
||||
if (0 == ref.fVerbCnt) {
|
||||
SkASSERT(0 == ref.fPointCnt);
|
||||
return true;
|
||||
}
|
||||
SkASSERT(this->verbsMemBegin() && ref.verbsMemBegin());
|
||||
if (0 != memcmp(this->verbsMemBegin(),
|
||||
ref.verbsMemBegin(),
|
||||
ref.fVerbCnt * sizeof(uint8_t))) {
|
||||
SkASSERT(!genIDMatch);
|
||||
return false;
|
||||
}
|
||||
SkASSERT(this->points() && ref.points());
|
||||
if (0 != memcmp(this->points(),
|
||||
ref.points(),
|
||||
ref.fPointCnt * sizeof(SkPoint))) {
|
||||
|
@ -3435,7 +3435,11 @@ static void compare_dump(skiatest::Reporter* reporter, const SkPath& path, bool
|
||||
path.dump(&wStream, force, dumpAsHex);
|
||||
SkAutoDataUnref data(wStream.copyToData());
|
||||
REPORTER_ASSERT(reporter, data->size() == strlen(str));
|
||||
REPORTER_ASSERT(reporter, !memcmp(data->data(), str, strlen(str)));
|
||||
if (strlen(str) > 0) {
|
||||
REPORTER_ASSERT(reporter, !memcmp(data->data(), str, strlen(str)));
|
||||
} else {
|
||||
REPORTER_ASSERT(reporter, data->data() == NULL || !memcmp(data->data(), str, strlen(str)));
|
||||
}
|
||||
}
|
||||
|
||||
static void test_dump(skiatest::Reporter* reporter) {
|
||||
|
Loading…
Reference in New Issue
Block a user