From e5d5d8189f058003c64b99863a411c010860e110 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 10 Jul 2013 20:19:36 +0800 Subject: [PATCH] Modules/IPStack - Added NULL checks in buffer code --- KernelLand/Modules/IPStack/buffer.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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; } } -- 2.20.1