Commit 75d40918 authored by Boaz Brickner's avatar Boaz Brickner

Merge pull request #68 from shargon/patch-1

Throw an exception if the buffer is null when creating a DataSegment.
parents 7d204fb5 aa011252
......@@ -23,15 +23,7 @@ namespace PcapDotNet.Packets
/// Take all the bytes as a segment.
/// </summary>
/// <param name="buffer">The buffer to take as a segment.</param>
public DataSegment(byte[] buffer)
{
if (buffer == null)
throw new ArgumentNullException("buffer");
Buffer = buffer;
StartOffset = 0;
Length = buffer.Length;
}
public DataSegment(byte[] buffer) : this(buffer, 0 , buffer == null ? 0 : buffer.Length) {}
/// <summary>
/// Take only part of the bytes as a segment.
......@@ -41,6 +33,9 @@ namespace PcapDotNet.Packets
/// <param name="length">The number of bytes to take.</param>
public DataSegment(byte[] buffer, int offset, int length)
{
if (buffer == null)
throw new ArgumentNullException("buffer");
Buffer = buffer;
StartOffset = offset;
Length = length;
......@@ -408,4 +403,4 @@ namespace PcapDotNet.Packets
private static readonly DataSegment _empty = new DataSegment(new byte[0]);
}
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment