diff --git a/CefSharp.Core/Internals/ClientAdapter.cpp b/CefSharp.Core/Internals/ClientAdapter.cpp index 9231c0a2a1..ede5a4e885 100644 --- a/CefSharp.Core/Internals/ClientAdapter.cpp +++ b/CefSharp.Core/Internals/ClientAdapter.cpp @@ -704,7 +704,19 @@ namespace CefSharp { auto resourceHandler = static_cast(handler); - return new CefStreamResourceHandler(StringUtils::ToNative(resourceHandler->MimeType), CefStreamReader::CreateForFile(StringUtils::ToNative(resourceHandler->FilePath))); + auto streamReader = CefStreamReader::CreateForFile(StringUtils::ToNative(resourceHandler->FilePath)); + + if (streamReader.get()) + { + return new CefStreamResourceHandler(StringUtils::ToNative(resourceHandler->MimeType), streamReader); + } + else + { + auto msg = "Unable to load resource CefStreamReader::CreateForFile returned NULL for file:" + resourceHandler->FilePath; + LOG(ERROR) << StringUtils::ToNative(msg).ToString(); + + return NULL; + } } else if (handler->GetType() == ByteArrayResourceHandler::typeid) { diff --git a/CefSharp.Core/SchemeHandlerFactoryWrapper.h b/CefSharp.Core/SchemeHandlerFactoryWrapper.h index 2ca2c5f38c..4bb2100aaa 100644 --- a/CefSharp.Core/SchemeHandlerFactoryWrapper.h +++ b/CefSharp.Core/SchemeHandlerFactoryWrapper.h @@ -48,7 +48,19 @@ namespace CefSharp { auto resourceHandler = static_cast(handler); - return new CefStreamResourceHandler(StringUtils::ToNative(resourceHandler->MimeType), CefStreamReader::CreateForFile(StringUtils::ToNative(resourceHandler->FilePath))); + auto streamReader = CefStreamReader::CreateForFile(StringUtils::ToNative(resourceHandler->FilePath)); + + if (streamReader.get()) + { + return new CefStreamResourceHandler(StringUtils::ToNative(resourceHandler->MimeType), streamReader); + } + else + { + auto msg = "Unable to load resource CefStreamReader::CreateForFile returned NULL for file:" + resourceHandler->FilePath; + LOG(ERROR) << StringUtils::ToNative(msg).ToString(); + + return NULL; + } } else if (handler->GetType() == ByteArrayResourceHandler::typeid) {