From e290d5ab238934ba48321db2cedc312649362f03 Mon Sep 17 00:00:00 2001 From: amaitland Date: Mon, 8 Jun 2020 16:24:30 +1000 Subject: [PATCH] Core - ByteArrayResourceHandler throw exception if byte[] length 0 We cannot create a CefStreamReader when buffer length is 0 CefStreamReader::CreateForData returns null and CefStreamResourceHandler crashes as the stream is null https://github.com/chromiumembedded/cef/blob/9df4a54308a88fd80c5774d91c62da35afb5fd1b/libcef/browser/stream_impl.cc#L27 https://github.com/chromiumembedded/cef/blob/a94dc6a0588e15deb184650b9015cd259e52a702/libcef_dll/wrapper/cef_stream_resource_handler.cc#L79 --- CefSharp/Internals/ByteArrayResourceHandler.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CefSharp/Internals/ByteArrayResourceHandler.cs b/CefSharp/Internals/ByteArrayResourceHandler.cs index 549030ce9..ac4adfbf0 100644 --- a/CefSharp/Internals/ByteArrayResourceHandler.cs +++ b/CefSharp/Internals/ByteArrayResourceHandler.cs @@ -43,6 +43,11 @@ namespace CefSharp throw new ArgumentNullException("data", "Please provide a valid array"); } + if (data.Length == 0) + { + throw new Exception("Unable to load byte[] with length 0."); + } + MimeType = mimeType; Data = data; }