Blame SOURCES/0005-Use-g_list_free_full-to-free-LRMetadataTarget-err.patch

e46568
From a5305e7f957666c92040fa0134d69d9fbeb5db70 Mon Sep 17 00:00:00 2001
e46568
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= <lhrazky@redhat.com>
e46568
Date: Tue, 16 Aug 2022 15:41:44 +0200
e46568
Subject: [PATCH] Use g_list_free_full() to free LRMetadataTarget::err
e46568
e46568
Fixes a memory leak where the char * items in the list were not freed.
e46568
---
e46568
 CMakeLists.txt                | 2 +-
e46568
 librepo.spec                  | 2 +-
e46568
 librepo/metadata_downloader.c | 3 +--
e46568
 3 files changed, 3 insertions(+), 4 deletions(-)
e46568
e46568
diff --git a/CMakeLists.txt b/CMakeLists.txt
e46568
index a45d5c4..b4007e3 100644
e46568
--- a/CMakeLists.txt
e46568
+++ b/CMakeLists.txt
e46568
@@ -28,7 +28,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
e46568
 # Find necessare libraries
e46568
 
e46568
 FIND_PACKAGE(PkgConfig)
e46568
-PKG_CHECK_MODULES(GLIB2 glib-2.0 REQUIRED)
e46568
+PKG_CHECK_MODULES(GLIB2 glib-2.0>=2.28 REQUIRED)
e46568
 PKG_SEARCH_MODULE(LIBCRYPTO REQUIRED libcrypto openssl)
e46568
 PKG_CHECK_MODULES(LIBXML2 libxml-2.0 REQUIRED)
e46568
 FIND_PACKAGE(CURL 7.52.0 REQUIRED)
e46568
diff --git a/librepo.spec b/librepo.spec
e46568
index 5a733b2..88d6d6d 100644
e46568
--- a/librepo.spec
e46568
+++ b/librepo.spec
e46568
@@ -23,7 +23,7 @@ BuildRequires:  cmake
e46568
 BuildRequires:  gcc
e46568
 BuildRequires:  check-devel
e46568
 BuildRequires:  doxygen
e46568
-BuildRequires:  pkgconfig(glib-2.0)
e46568
+BuildRequires:  pkgconfig(glib-2.0) >= 2.28
e46568
 BuildRequires:  gpgme-devel
e46568
 BuildRequires:  libattr-devel
e46568
 BuildRequires:  libcurl-devel >= %{libcurl_version}
e46568
diff --git a/librepo/metadata_downloader.c b/librepo/metadata_downloader.c
e46568
index 92a462b..cda1e40 100644
e46568
--- a/librepo/metadata_downloader.c
e46568
+++ b/librepo/metadata_downloader.c
e46568
@@ -89,8 +89,7 @@ lr_metadatatarget_free(LrMetadataTarget *target)
e46568
     if (!target)
e46568
         return;
e46568
     g_string_chunk_free(target->chunk);
e46568
-    if (target->err != NULL)
e46568
-        g_list_free(target->err);
e46568
+    g_list_free_full(target->err, g_free);
e46568
     g_free(target);
e46568
 }
e46568
 
e46568
-- 
e46568
2.37.1
e46568