From 1663b19c873d5e60038642d810194638cfcaf690 Mon Sep 17 00:00:00 2001 From: chylex Date: Fri, 21 Jan 2022 06:09:35 +0100 Subject: [PATCH] Fix not disposing callback in ResourceHandler.Skip (#3978) --- CefSharp.Example/AcceptRangeResourceHandler.cs | 3 +++ CefSharp/ResourceHandler.cs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/CefSharp.Example/AcceptRangeResourceHandler.cs b/CefSharp.Example/AcceptRangeResourceHandler.cs index 27f916272a..4f48712935 100644 --- a/CefSharp.Example/AcceptRangeResourceHandler.cs +++ b/CefSharp.Example/AcceptRangeResourceHandler.cs @@ -151,6 +151,9 @@ private bool TryGetRangeHeader(out string contentRange, out int contentLength) bool IResourceHandler.Skip(long bytesToSkip, out long bytesSkipped, IResourceSkipCallback callback) { + //We don't need the callback, as it's an unmanaged resource we should dispose it (could wrap it in a using statement). + callback.Dispose(); + //No Stream or Stream cannot seek then we indicate failure if (stream == null || !stream.CanSeek) { diff --git a/CefSharp/ResourceHandler.cs b/CefSharp/ResourceHandler.cs index b15091eb47..d5fa8dbe3b 100644 --- a/CefSharp/ResourceHandler.cs +++ b/CefSharp/ResourceHandler.cs @@ -138,6 +138,9 @@ bool IResourceHandler.Open(IRequest request, out bool handleRequest, ICallback c bool IResourceHandler.Skip(long bytesToSkip, out long bytesSkipped, IResourceSkipCallback callback) { + //We don't need the callback, as it's an unmanaged resource we should dispose it (could wrap it in a using statement). + callback.Dispose(); + //No Stream or Stream cannot seek then we indicate failure if (Stream == null || !Stream.CanSeek) {