From: John Hodge Date: Wed, 10 Jul 2013 12:19:36 +0000 (+0800) Subject: Modules/IPStack - Added NULL checks in buffer code X-Git-Tag: rel0.15~380 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=e5d5d8189f058003c64b99863a411c010860e110;p=tpg%2Facess2.git Modules/IPStack - Added NULL checks in buffer code --- diff --git a/KernelLand/Modules/IPStack/buffer.c b/KernelLand/Modules/IPStack/buffer.c index 2555a635..727511eb 100644 --- a/KernelLand/Modules/IPStack/buffer.c +++ b/KernelLand/Modules/IPStack/buffer.c @@ -172,8 +172,10 @@ int IPStack_Buffer_GetBuffer(tIPStackBuffer *Buffer, int Index, size_t *Length, return -1; } - *DataPtr = (Uint8*)Buffer->SubBuffers[Index].Data + Buffer->SubBuffers[Index].PreLength; - *Length = Buffer->SubBuffers[Index].PostLength; + if( DataPtr ) + *DataPtr = (Uint8*)Buffer->SubBuffers[Index].Data + Buffer->SubBuffers[Index].PreLength; + if( Length ) + *Length = Buffer->SubBuffers[Index].PostLength; return (Index + 1) + Buffer->nSubBuffers; } @@ -182,8 +184,10 @@ int IPStack_Buffer_GetBuffer(tIPStackBuffer *Buffer, int Index, size_t *Length, int rv = Index + 1; Index = Buffer->nSubBuffers - Index - 1; // Prepended buffers - *DataPtr = Buffer->SubBuffers[Index].Data; - *Length = Buffer->SubBuffers[Index].PreLength; + if( DataPtr ) + *DataPtr = Buffer->SubBuffers[Index].Data; + if( Length ) + *Length = Buffer->SubBuffers[Index].PreLength; return rv; } }