diff --git a/rpcs3/Loader/TAR.cpp b/rpcs3/Loader/TAR.cpp index 4eb568c3b7..5891f0e51e 100644 --- a/rpcs3/Loader/TAR.cpp +++ b/rpcs3/Loader/TAR.cpp @@ -568,8 +568,9 @@ void tar_object::save_directory(const std::string& target_path, utils::serial& a auto save_header = [&](const fs::stat_t& stat, std::string_view name) { static_assert(sizeof(TARHeader) == 512); + ensure(src_dir_pos <= name.size()); - std::string_view saved_path = name.size() == src_dir_pos ? name : name.substr(src_dir_pos); + std::string_view saved_path = name.size() == src_dir_pos ? std::string_view() : name.substr(src_dir_pos); if (is_null) {