[PATCH 05/14] productfilter: Fix GDate leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



osinfo_productfilter_matches_default() was not freeing the GDate
instances returned by osinfo_product_get_{release,eol}_date().

This fixes:

==14496== 16 bytes in 2 blocks are definitely lost in loss record 141 of 382
==14496==    at 0x4C2BBAD: malloc (vg_replace_malloc.c:299)
==14496==    by 0x684FE58: g_malloc (gmem.c:94)
==14496==    by 0x6830114: g_date_new_dmy (gdate.c:289)
==14496==    by 0x5337012: date_from_string (osinfo_product.c:345)
==14496==    by 0x533706D: osinfo_product_get_release_date (osinfo_product.c:354)
==14496==    by 0x5337F6F: osinfo_productfilter_matches_default (osinfo_productfilter.c:279)
==14496==    by 0x532CC8D: osinfo_filter_matches (osinfo_filter.c:288)
==14496==    by 0x532D51B: osinfo_list_add_filtered (osinfo_list.c:272)
==14496==    by 0x532DD52: osinfo_list_new_filtered (osinfo_list.c:443)
==14496==    by 0x401B35: test_supportdate (test-product.c:140)
==14496==    by 0x5117535: tcase_run_tfun_nofork.isra.9 (check_run.c:390)
==14496==    by 0x51178EB: srunner_iterate_tcase_tfuns (check_run.c:231)
==14496==    by 0x51178EB: srunner_run_tcase (check_run.c:373)
==14496==    by 0x51178EB: srunner_iterate_suites (check_run.c:195)
==14496==    by 0x51178EB: srunner_run (check_run.c:782)
==14496==    by 0x40166E: main (test-product.c:219)
==14496==-
==14496== 16 bytes in 2 blocks are definitely lost in loss record 142 of 382
==14496==    at 0x4C2BBAD: malloc (vg_replace_malloc.c:299)
==14496==    by 0x684FE58: g_malloc (gmem.c:94)
==14496==    by 0x6830114: g_date_new_dmy (gdate.c:289)
==14496==    by 0x5337012: date_from_string (osinfo_product.c:345)
==14496==    by 0x53370C8: osinfo_product_get_eol_date (osinfo_product.c:364)
==14496==    by 0x5337F92: osinfo_productfilter_matches_default (osinfo_productfilter.c:280)
==14496==    by 0x532CC8D: osinfo_filter_matches (osinfo_filter.c:288)
==14496==    by 0x532D51B: osinfo_list_add_filtered (osinfo_list.c:272)
==14496==    by 0x532DD52: osinfo_list_new_filtered (osinfo_list.c:443)
==14496==    by 0x401B35: test_supportdate (test-product.c:140)
==14496==    by 0x5117535: tcase_run_tfun_nofork.isra.9 (check_run.c:390)
==14496==    by 0x51178EB: srunner_iterate_tcase_tfuns (check_run.c:231)
==14496==    by 0x51178EB: srunner_run_tcase (check_run.c:373)
==14496==    by 0x51178EB: srunner_iterate_suites (check_run.c:195)
==14496==    by 0x51178EB: srunner_run (check_run.c:782)
==14496==    by 0x40166E: main (test-product.c:219)
---
 osinfo/osinfo_productfilter.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/osinfo/osinfo_productfilter.c b/osinfo/osinfo_productfilter.c
index 9dbffa2..70f4a91 100644
--- a/osinfo/osinfo_productfilter.c
+++ b/osinfo/osinfo_productfilter.c
@@ -276,16 +276,26 @@ static gboolean osinfo_productfilter_matches_default(OsinfoFilter *filter, Osinf
 
     if (productfilter->priv->supportDate) {
         GDate *when = productfilter->priv->supportDate;
-        GDate *release = osinfo_product_get_release_date(OSINFO_PRODUCT(entity));
-        GDate *eol = osinfo_product_get_eol_date(OSINFO_PRODUCT(entity));
+        GDate *release;
+        GDate *eol;
 
-        if (release &&
-            (g_date_compare(release, when) > 0))
-            return FALSE;
+        release = osinfo_product_get_release_date(OSINFO_PRODUCT(entity));
+        if (release != NULL) {
+            gboolean newer;
+            newer = (g_date_compare(release, when) > 0);
+            g_date_free(release);
+            if (newer)
+                return FALSE;
+        }
 
-        if (eol &&
-            (g_date_compare(eol, when) < 0))
-            return FALSE;
+        eol = osinfo_product_get_eol_date(OSINFO_PRODUCT(entity));
+        if (eol != NULL) {
+            gboolean older;
+            older = (g_date_compare(eol, when) < 0);
+            g_date_free(eol);
+            if (older)
+                return FALSE;
+        }
     }
 
     return args.matched;
-- 
2.7.4

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux