Only release the image data in the unit-test once Skia has accepted ownership of it. (flutter/engine#9816)

Fixes UB which caused failures on Windows on the unit-test run.
This commit is contained in:
Chinmay Garde
2019-07-12 13:03:17 -07:00
committed by GitHub
parent 915fe6fad7
commit fc8d8ad4b0

View File

@@ -91,9 +91,16 @@ static sk_sp<SkData> OpenFixtureAsSkData(const char* name) {
delete reinterpret_cast<fml::FileMapping*>(context);
};
return SkData::MakeWithProc(fixture_mapping->GetMapping(),
fixture_mapping->GetSize(), on_release,
fixture_mapping.release());
auto data = SkData::MakeWithProc(fixture_mapping->GetMapping(),
fixture_mapping->GetSize(), on_release,
fixture_mapping.get());
if (!data) {
return nullptr;
}
// The data is now owned by Skia.
fixture_mapping.release();
return data;
}
TEST_F(ImageDecoderFixtureTest, CanCreateImageDecoder) {