Modules/IPStack - Added NULL checks in buffer code
authorJohn Hodge <[email protected]>
Wed, 10 Jul 2013 12:19:36 +0000 (20:19 +0800)
committerJohn Hodge <[email protected]>
Wed, 10 Jul 2013 12:19:36 +0000 (20:19 +0800)
KernelLand/Modules/IPStack/buffer.c

index 2555a63..727511e 100644 (file)
@@ -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;
        }
 }

UCC git Repository :: git.ucc.asn.au