Skip to content

Commit

Permalink
Fix local file loading and crash on loading non-existent file
Browse files Browse the repository at this point in the history
  • Loading branch information
PatTheMav committed Nov 26, 2021
1 parent b1303ba commit c8f3434
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions browser-scheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@ BrowserSchemeHandlerFactory::Create(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefStreamReader> stream =
CefStreamReader::CreateForFile(path);
#endif

return new CefStreamResourceHandler(CefGetMimeType(fileExtension),
stream);

if (stream) {
return new CefStreamResourceHandler(CefGetMimeType(fileExtension),
stream);
} else {
return nullptr;
}

}
#endif
2 changes: 1 addition & 1 deletion browser-scheme.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <string>
#include <fstream>

#if CHROME_VERSION_BUILD >= 3440
#if CHROME_VERSION_BUILD >= 3440 && CHROME_VERSION_BUILD < 4638
#define ENABLE_LOCAL_FILE_URL_SCHEME 1
#else
#define ENABLE_LOCAL_FILE_URL_SCHEME 0
Expand Down

0 comments on commit c8f3434

Please sign in to comment.