From fa2d261c69ed631380139732617753bcbb5263e7 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Tue, 9 May 2017 08:38:08 +0200 Subject: [PATCH] src/liboping.c: Don't check for NULL when calling free(). free(3) handles NULL pointers correctly, so these checks are not needed. --- src/liboping.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/liboping.c b/src/liboping.c index b6c80f2..0c9016e 100644 --- a/src/liboping.c +++ b/src/liboping.c @@ -957,14 +957,12 @@ static pinghost_t *ping_alloc (void) static void ping_free (pinghost_t *ph) { - if (ph->username != NULL) - free (ph->username); - - if (ph->hostname != NULL) - free (ph->hostname); + if (ph == NULL) + return; - if (ph->data != NULL) - free (ph->data); + free (ph->username); + free (ph->hostname); + free (ph->data); free (ph); } @@ -1172,14 +1170,9 @@ void ping_destroy (pingobj_t *obj) current = next; } - if (obj->data != NULL) - free (obj->data); - - if (obj->srcaddr != NULL) - free (obj->srcaddr); - - if (obj->device != NULL) - free (obj->device); + free (obj->data); + free (obj->srcaddr); + free (obj->device); if (obj->fd4 != -1) close(obj->fd4); -- 2.30.2