richardphibel / rpms / libdnf

Forked from rpms/libdnf 2 years ago
Clone

Blame SOURCES/0020-Fix-dnf_context_module_install-memory-leaks.patch

379fd8
From 4a8a3f410552c58dfafb384bb361c6e40bebff1d Mon Sep 17 00:00:00 2001
379fd8
From: Jaroslav Rohel <jrohel@redhat.com>
379fd8
Date: Wed, 21 Jul 2021 11:01:32 +0200
379fd8
Subject: [PATCH] Fix: dnf_context_module_install: memory leaks
379fd8
379fd8
---
379fd8
 libdnf/dnf-context.cpp | 5 ++++-
379fd8
 1 file changed, 4 insertions(+), 1 deletion(-)
379fd8
379fd8
diff --git a/libdnf/dnf-context.cpp b/libdnf/dnf-context.cpp
379fd8
index 55af2b2..6cb0011 100644
379fd8
--- a/libdnf/dnf-context.cpp
379fd8
+++ b/libdnf/dnf-context.cpp
379fd8
@@ -3486,7 +3486,10 @@ dnf_context_module_install(DnfContext * context, const char ** module_specs, GEr
379fd8
                         }
379fd8
                         for (const auto &nevra : modpkg->getArtifacts()) {
379fd8
                             int epoch;
379fd8
-                            char *name, *version, *release, *arch;
379fd8
+                            g_autofree char *name = nullptr;
379fd8
+                            g_autofree char *version = nullptr;
379fd8
+                            g_autofree char *release = nullptr;
379fd8
+                            g_autofree char *arch = nullptr;
379fd8
                             if (hy_split_nevra(nevra.c_str(), &name, &epoch, &version, &release, &arch)) {
379fd8
                                 // this really should never happen; unless the modular repodata is corrupted
379fd8
                                 g_autofree char *errmsg = g_strdup_printf (_("Failed to parse module artifact NEVRA '%s'"), nevra.c_str());
379fd8
--
379fd8
libgit2 1.0.1
379fd8