From: Cameron Gutman Date: Wed, 21 Oct 2009 03:49:44 +0000 (+0000) Subject: - Don't allocate a buffer if we don't have any neighbors X-Git-Tag: ReactOS-0.3.11~353 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=a5f9cb6d11e6cd4844e604946f377d00a41bd2e2 - Don't allocate a buffer if we don't have any neighbors svn path=/trunk/; revision=43664 --- diff --git a/reactos/drivers/network/tcpip/tcpip/iinfo.c b/reactos/drivers/network/tcpip/tcpip/iinfo.c index f16e1e2bf44..38e649ff1f8 100644 --- a/reactos/drivers/network/tcpip/tcpip/iinfo.c +++ b/reactos/drivers/network/tcpip/tcpip/iinfo.c @@ -113,16 +113,23 @@ TDI_STATUS InfoTdiQueryGetArptableMIB(TDIEntityID ID, NTSTATUS Status; ULONG NumNeighbors = NBCopyNeighbors( Interface, NULL ); ULONG MemSize = NumNeighbors * sizeof(IPARP_ENTRY); - PIPARP_ENTRY ArpEntries = - exAllocatePoolWithTag - ( NonPagedPool, MemSize, FOURCC('A','R','P','t') ); + PIPARP_ENTRY ArpEntries; - if( !ArpEntries ) return STATUS_NO_MEMORY; - NBCopyNeighbors( Interface, ArpEntries ); + if (MemSize != 0) + { + ArpEntries = exAllocatePoolWithTag( NonPagedPool, MemSize, FOURCC('A','R','P','t') ); + if( !ArpEntries ) return STATUS_NO_MEMORY; - Status = InfoCopyOut( (PVOID)ArpEntries, MemSize, Buffer, BufferSize ); + NBCopyNeighbors( Interface, ArpEntries ); - exFreePool( ArpEntries ); + Status = InfoCopyOut( (PVOID)ArpEntries, MemSize, Buffer, BufferSize ); + + exFreePool( ArpEntries ); + } + else + { + Status = InfoCopyOut(NULL, 0, NULL, BufferSize); + } return Status; }