From 38d84047c685ffd9409fc10fec1f02b095d98aed Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Thu, 15 Sep 2011 14:33:14 +0200 Subject: [PATCH] dccp_recv: Avoid NULL pointer dereference. dccp_recv.c:48:16: warning: Access to field 'btrp' results in a dereference of a null pointer (loaded from variable 'pdd') btr_pool_free(pdd->btrp); ^~~ In dccp_recv_close(), if pdd is NULL, we avoid closing pdd->fd but dereference pdd nevertheless one line later. Fix this by returning early if pdd is NULL. --- dccp_recv.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dccp_recv.c b/dccp_recv.c index af8e6b16..a9eab006 100644 --- a/dccp_recv.c +++ b/dccp_recv.c @@ -40,13 +40,14 @@ struct private_dccp_recv_data { static void dccp_recv_close(struct receiver_node *rn) { - struct private_dccp_recv_data *pdd = rn->private_data; - if (pdd && pdd->fd > 0) + if (!pdd) + return; + if (pdd->fd > 0) close(pdd->fd); btr_pool_free(pdd->btrp); - free(rn->private_data); + free(pdd); rn->private_data = NULL; } -- 2.39.5