srctree

Robin Linden parent 7d08b2c8 2866fa8c
browser/gui: Fix crash on favicon image data load failure

We were accessing error() of a tl::expected when downloading the faviconworked but SFML failed to load it as an image.

Introduced in 7622d7444a095980cad794658e5b888ceeacdb58.

inlinesplit
browser/gui/app.cpp added: 7, removed: 2, total 5
@@ -583,11 +583,16 @@ void App::on_page_loaded() {
 
auto icon = engine_.load(*uri).response;
sf::Image favicon;
if (!icon.has_value() || !favicon.loadFromMemory(icon->body.data(), icon->body.size())) {
if (!icon.has_value()) {
spdlog::warn("Error loading favicon from '{}': {}", uri->uri, to_string(icon.error().err));
continue;
}
 
if (!favicon.loadFromMemory(icon->body.data(), icon->body.size())) {
spdlog::warn("Error parsing favicon data from '{}'", uri->uri);
continue;
}
 
window_.setIcon(favicon.getSize().x, favicon.getSize().y, favicon.getPixelsPtr());
break;
}