Fix Memory Leak in MakeSkSurfaceFromBackingStore (flutter/engine#30735)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user