Fix SkData leaks at GrResourceKey::setCustomData() call sites.

BUG=skia:
TBR=bsalomon@google.com

Review URL: https://codereview.chromium.org/1270103003 .
This commit is contained in:
Stephen White 2015-08-03 21:53:09 -04:00
parent 1d183b4cb3
commit c369348aa5
2 changed files with 6 additions and 3 deletions

View File

@ -1489,7 +1489,8 @@ public:
TessInfo info;
info.fTolerance = isLinear ? 0 : tol;
info.fCount = actualCount;
key->setCustomData(SkData::NewWithCopy(&info, sizeof(info)));
SkAutoTUnref<SkData> data(SkData::NewWithCopy(&info, sizeof(info)));
key->setCustomData(data.get());
resourceProvider->assignUniqueKeyToResource(*key, vertexBuffer.get());
SkPathPriv::AddGenIDChangeListener(fPath, SkNEW(PathInvalidator(*key)));
}

View File

@ -851,7 +851,8 @@ static void test_duplicate_unique_key(skiatest::Reporter* reporter) {
make_unique_key<0>(&key2, 0);
SkAutoTUnref<TestResource> d(SkNEW_ARGS(TestResource, (context->getGpu())));
int foo = 4132;
key2.setCustomData(SkData::NewWithCopy(&foo, sizeof(foo)));
SkAutoTUnref<SkData> data(SkData::NewWithCopy(&foo, sizeof(foo)));
key2.setCustomData(data.get());
d->resourcePriv().setUniqueKey(key2);
}
@ -1242,7 +1243,8 @@ static void test_custom_data(skiatest::Reporter* reporter) {
make_unique_key<0>(&key1, 1);
make_unique_key<0>(&key2, 2);
int foo = 4132;
key1.setCustomData(SkData::NewWithCopy(&foo, sizeof(foo)));
SkAutoTUnref<SkData> data(SkData::NewWithCopy(&foo, sizeof(foo)));
key1.setCustomData(data.get());
REPORTER_ASSERT(reporter, *(int*) key1.getCustomData()->data() == 4132);
REPORTER_ASSERT(reporter, key2.getCustomData() == nullptr);