]> git.itanic.dy.fi Git - rrdd/commitdiff
netstat_parser: Fix file descriptor leak
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Mon, 11 Jul 2016 04:10:26 +0000 (07:10 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Mon, 11 Jul 2016 04:10:26 +0000 (07:10 +0300)
Once data is read, close the descriptor to prevent a leak.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
built_in_parsers.c

index f86da28efa9317762b1c6cc904d318e60ad5fb88..9a0d342cf2d9c749994fc3b07a8ab8f0268ffcf2 100644 (file)
@@ -238,9 +238,11 @@ static int get_iface_stats(const char *iface, struct iface_stats *stat)
                        stat->rx_bytes, stat->rx_packets,
                        stat->tx_bytes, stat->tx_packets);
 
                        stat->rx_bytes, stat->rx_packets,
                        stat->tx_bytes, stat->tx_packets);
 
+               fclose(netdev);
                return 0;
        }
 
                return 0;
        }
 
+       fclose(netdev);
        pr_err("Interface %s not found\n", iface);
        return -ENODEV;
 }
        pr_err("Interface %s not found\n", iface);
        return -ENODEV;
 }