memleak and make valgrind happy
[ppastats.git] / src / lp.c
index 3219f11..67e6ed5 100644 (file)
--- a/src/lp.c
+++ b/src/lp.c
@@ -91,14 +91,18 @@ struct bpph *bpph_new(const char *binary_package_name,
 
 void bpph_list_free(struct bpph **list)
 {
-       struct bpph **l_cur = list;
+       struct bpph **cur;
 
-       while (*l_cur) {
-               bpph_free(*l_cur);
-               l_cur++;
-       }
+       if (list) {
+               cur = list;
 
-       free(list);
+               while (*cur) {
+                       bpph_free(*cur);
+                       cur++;
+               }
+
+               free(list);
+       }
 }
 
 char *get_archive_url(const char *owner, const char *ppa)
@@ -150,10 +154,13 @@ void distro_arch_series_free(struct distro_arch_series *d)
 
 void distro_arch_series_list_free(struct distro_arch_series **list)
 {
+       struct distro_arch_series **cur;
+
        if (list) {
-               while (*list) {
-                       distro_arch_series_free(*list);
-                       list++;
+               cur = list;
+               while (*cur) {
+                       distro_arch_series_free(*cur);
+                       cur++;
                }
                free(list);
        }