From c8ff03d6822f013ebc4a955de5f10b4cbf7bc681 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 29 Aug 2010 02:29:10 +0000 Subject: [PATCH] [TCPIP] - Don't allocate pool if there is nothing in the route table - Fixes bug 5493 svn path=/trunk/; revision=48637 --- reactos/drivers/network/tcpip/tcpip/ninfo.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/reactos/drivers/network/tcpip/tcpip/ninfo.c b/reactos/drivers/network/tcpip/tcpip/ninfo.c index 293eb19a027..f78d4b40062 100644 --- a/reactos/drivers/network/tcpip/tcpip/ninfo.c +++ b/reactos/drivers/network/tcpip/tcpip/ninfo.c @@ -21,15 +21,21 @@ TDI_STATUS InfoTdiQueryGetRouteTable( PIP_INTERFACE IF, PNDIS_BUFFER Buffer, PUI KIRQL OldIrql; UINT RtCount = CountFIBs(IF); UINT Size = sizeof( IPROUTE_ENTRY ) * RtCount; - PFIB_ENTRY RCache = - ExAllocatePool( NonPagedPool, sizeof( FIB_ENTRY ) * RtCount ), - RCacheCur = RCache; - PIPROUTE_ENTRY RouteEntries = ExAllocatePool( NonPagedPool, Size ), - RtCurrent = RouteEntries; + PFIB_ENTRY RCache, RCacheCur; + PIPROUTE_ENTRY RouteEntries, RtCurrent; UINT i; - TI_DbgPrint(DEBUG_INFO, ("Called, routes = %d, RCache = %08x\n", - RtCount, RCache)); + TI_DbgPrint(DEBUG_INFO, ("Called, routes = %d\n", + RtCount)); + + if (RtCount == 0) + return InfoCopyOut(NULL, 0, NULL, BufferSize); + + RouteEntries = ExAllocatePool( NonPagedPool, Size ); + RtCurrent = RouteEntries; + + RCache = ExAllocatePool( NonPagedPool, sizeof( FIB_ENTRY ) * RtCount ); + RCacheCur = RCache; if( !RCache || !RouteEntries ) { if( RCache ) ExFreePool( RCache );