From a361dabddcc342ef3c0d4023f8500b16364889a3 Mon Sep 17 00:00:00 2001
From: Jan Kolarik <jkolarik@redhat.com>
Date: Wed, 10 Aug 2022 05:21:38 +0000
Subject: [PATCH] Fix listing a repository without cpeid (RhBug:2066334)

Conflict:NA
Reference:https://github.com/rpm-software-management/libdnf/commit/a361dabddcc342ef3c0d4023f8500b16364889a3

= changelog =
type: bugfix
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2066334
---
 libdnf/repo/Repo.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libdnf/repo/Repo.cpp b/libdnf/repo/Repo.cpp
index e1d5529327..557f727fdf 100644
--- a/libdnf/repo/Repo.cpp
+++ b/libdnf/repo/Repo.cpp
@@ -1031,8 +1031,13 @@ bool Repo::Impl::loadCache(bool throwExcept, bool ignoreMissing)
     for (auto elem = yum_repomd->distro_tags; elem; elem = g_slist_next(elem)) {
         if (elem->data) {
             auto distroTag = static_cast<LrYumDistroTag *>(elem->data);
-            if (distroTag->tag)
-                distro_tags.emplace_back(distroTag->cpeid, distroTag->tag);
+            if (distroTag->tag) {
+                std::string cpeid_str;
+                if (distroTag->cpeid) {
+                    cpeid_str = distroTag->cpeid;
+                }
+                distro_tags.emplace_back(std::move(cpeid_str), distroTag->tag);
+            }
         }
     }
 
