diff options
author | Francis Dupont <fdupont@isc.org> | 2015-06-27 13:20:22 +0200 |
---|---|---|
committer | Francis Dupont <fdupont@isc.org> | 2015-06-27 13:20:22 +0200 |
commit | 65c611f2817ec98c230520b7eba6c4c2d51c34e7 (patch) | |
tree | 4f9a0c95d0fa7905e8613e6ba0a313fe7110044c /src/lib/dhcp | |
parent | [3920] Removed reinit of data_ (diff) | |
download | kea-65c611f2817ec98c230520b7eba6c4c2d51c34e7.tar.xz kea-65c611f2817ec98c230520b7eba6c4c2d51c34e7.zip |
[3920] Applied proposed cleanup of Pkt{,4} buf/len constructor
Diffstat (limited to 'src/lib/dhcp')
-rw-r--r-- | src/lib/dhcp/pkt.cc | 8 | ||||
-rw-r--r-- | src/lib/dhcp/pkt4.cc | 3 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/lib/dhcp/pkt.cc b/src/lib/dhcp/pkt.cc index 82e5319c39..dfd1f8aa33 100644 --- a/src/lib/dhcp/pkt.cc +++ b/src/lib/dhcp/pkt.cc @@ -48,8 +48,12 @@ Pkt::Pkt(const uint8_t* buf, uint32_t len, const isc::asiolink::IOAddress& local remote_port_(remote_port), buffer_out_(0) { - data_.resize(len); - if (len) { + + if (len != 0) { + if (buf == NULL) { + isc_throw(InvalidParameter, "data buffer passed to Pkt is NULL"); + } + data_.resize(len); memcpy(&data_[0], buf, len); } } diff --git a/src/lib/dhcp/pkt4.cc b/src/lib/dhcp/pkt4.cc index c56c166959..1a406f87c9 100644 --- a/src/lib/dhcp/pkt4.cc +++ b/src/lib/dhcp/pkt4.cc @@ -74,9 +74,6 @@ Pkt4::Pkt4(const uint8_t* data, size_t len) isc_throw(OutOfRange, "Truncated DHCPv4 packet (len=" << len << ") received, at least " << DHCPV4_PKT_HDR_LEN << " is expected."); - - } else if (data == NULL) { - isc_throw(InvalidParameter, "data buffer passed to Pkt4 is NULL"); } } |