From 5d69e391e43b65f172fdd91fb1b0e276ea191903 Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Sun, 25 Oct 2026 23:22:33 +0100 Subject: [PATCH] Fix crash when loading Steam games on flatpak --- common/utils/steam_info.cpp | 27 +++++++++++++++++---------- common/utils/vdf.cpp | 17 ++++++++++++----- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/common/utils/steam_info.cpp b/common/utils/steam_info.cpp index fe20e820..5d9e6c54 100644 --- a/common/utils/steam_info.cpp +++ b/common/utils/steam_info.cpp @@ -177,21 +177,26 @@ std::optional guess_steam_userid(const std::filesystem::path & root) std::unordered_set installed_appids(std::filesystem::path root) { - wivrn::vdf::root vdf(root / "config/libraryfolders.vdf"); - using values_t = std::vector; - if (vdf.key != "libraryfolders") - return {}; - std::unordered_set res; - for (const auto & kv: std::get(vdf.value)) + try { - for (const auto & [appid, _]: std::get(kv["apps"].value)) + wivrn::vdf::root vdf(root / "config/libraryfolders.vdf"); + using values_t = std::vector; + if (vdf.key != "libraryfolders") + return {}; + + for (const auto & kv: std::get(vdf.value)) { - uint64_t val; - if (std::from_chars(appid.data.begin(), appid.data.end(), val).ec == std::errc()) - res.emplace(val); + for (const auto & [appid, _]: std::get(kv["apps"].value)) + { + uint64_t val; + if (std::from_chars(appid.data.begin(), appid.data.end(), val).ec == std::errc()) + res.emplace(val); + } } } + catch (...) + {} return res; } @@ -476,6 +481,7 @@ std::vector wivrn::steam::list_applications() } catch (std::exception & e) { + std::cerr << "Listing Steam applications failed (user id " << *default_userid << "): " << e.what() << std::endl; } } else @@ -496,6 +502,7 @@ std::vector wivrn::steam::list_applications() } catch (std::exception & e) { + std::cerr << "Listing Steam applications failed (" << entry.path().filename() << "): " << e.what() << std::endl; } } diff --git a/common/utils/vdf.cpp b/common/utils/vdf.cpp index ccf202ae..db0bbdf2 100644 --- a/common/utils/vdf.cpp +++ b/common/utils/vdf.cpp @@ -145,12 +145,19 @@ wivrn::vdf::keyvalue const & wivrn::vdf::keyvalue::operator[](const char * key) wivrn::vdf::root::root(const std::filesystem::path & file) { - boost::iostreams::mapped_file in{file}; - opaque = in; + try + { + boost::iostreams::mapped_file_source in{file}; + opaque = in; - const char * pos = in.begin(); - key = read_string(pos, in.end()); - value = read_value(pos, in.end()); + const char * pos = in.begin(); + key = read_string(pos, in.end()); + value = read_value(pos, in.end()); + } + catch (std::exception & e) + { + throw std::runtime_error(std::format("failed to parse {}: {}", file.native(), e.what())); + } } void dump(const wivrn::vdf::keyvalue & kv, int depth)