Fix Memory Leak in MakeSkSurfaceFromBackingStore (flutter/engine#30735)

This commit is contained in:
Lyle Dean 2022-01-24 15:55:11 +00:00 committed by GitHub
parent 40365e0cbb
commit bcbd90ac89

View File

@ -558,6 +558,7 @@ static sk_sp<SkSurface> MakeSkSurfaceFromBackingStore(
if (captures->destruction_callback) {
captures->destruction_callback(captures->user_data);
}
delete captures;
};
auto surface = SkSurface::MakeRasterDirectReleaseProc(
@ -565,7 +566,7 @@ static sk_sp<SkSurface> MakeSkSurfaceFromBackingStore(
const_cast<void*>(software->allocation), // pixels
software->row_bytes, // row bytes
release_proc, // release proc
captures.release() // release context
captures.get() // get context
);
if (!surface) {
@ -576,6 +577,9 @@ static sk_sp<SkSurface> MakeSkSurfaceFromBackingStore(
}
return nullptr;
}
if (surface) {
captures.release(); // Skia has assumed ownership of the struct.
}
return surface;
}