s4-dns: Fix an unlikely potential memleak
authorVolker Lendecke <vl@samba.org>
Thu, 24 May 2012 13:59:32 +0000 (15:59 +0200)
committerKai Blin <kai@samba.org>
Tue, 29 May 2012 22:37:53 +0000 (00:37 +0200)
If state was alloc'ed to NULL, in_packet to != NULL and out_packet to NULL, we
leak in_packet.

Signed-off-by: Kai Blin <kai@samba.org>
source4/dns_server/dns_server.c

index f9db095e744965ae2d7c5b91b09d2505c8903e0e..28c57c0f6ebad9560c663d6e52043d047cdfd732 100644 (file)
@@ -117,8 +117,10 @@ static NTSTATUS dns_process(struct dns_server *dns,
        /* TODO: We don't really need an out_packet. */
        out_packet = talloc_zero(state, struct dns_name_packet);
 
-       if (in_packet == NULL) return NT_STATUS_NO_MEMORY;
-       if (out_packet == NULL) return NT_STATUS_NO_MEMORY;
+       if ((state == NULL) || (in_packet == NULL) || (out_packet == NULL)) {
+               TALLOC_FREE(state);
+               return NT_STATUS_NO_MEMORY;
+       }
 
        dump_data(8, in->data, in->length);