iptables: Fix memory leak
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Fri, 23 Sep 2011 11:43:38 +0000 (14:43 +0300)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 29 Sep 2011 15:52:59 +0000 (17:52 +0200)
src/iptables.c

index 78ad210..a8167ee 100644 (file)
@@ -633,7 +633,7 @@ iptables_add_rule(struct connman_iptables *table,
        GList *chain_tail, *chain_head;
        struct ipt_entry *new_entry;
        struct connman_iptables_entry *head;
-       int builtin = -1;
+       int builtin = -1, ret;
 
        DBG("");
 
@@ -666,7 +666,11 @@ iptables_add_rule(struct connman_iptables *table,
                head->builtin = -1;
        }
 
-       return iptables_add_entry(table, new_entry, chain_tail->prev, builtin);
+       ret = iptables_add_entry(table, new_entry, chain_tail->prev, builtin);
+       if (ret < 0)
+               g_free(new_entry);
+
+       return ret;
 }
 
 static struct ipt_replace *