dccp_recv: Avoid NULL pointer dereference.
authorAndre Noll <maan@systemlinux.org>
Thu, 15 Sep 2011 12:33:14 +0000 (14:33 +0200)
committerAndre Noll <maan@systemlinux.org>
Wed, 21 Sep 2011 09:04:12 +0000 (11:04 +0200)
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

index af8e6b1657e86777af5f6360c573c60bcc46e93c..a9eab006bd3cf0f0d4ddc6e5ac41ba6beb30199a 100644 (file)
@@ -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;
 }