]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3920] Applied proposed cleanup of Pkt{,4} buf/len constructor trac3915a_base
authorFrancis Dupont <fdupont@isc.org>
Sat, 27 Jun 2015 11:20:22 +0000 (13:20 +0200)
committerFrancis Dupont <fdupont@isc.org>
Sat, 27 Jun 2015 11:20:22 +0000 (13:20 +0200)
src/lib/dhcp/pkt.cc
src/lib/dhcp/pkt4.cc

index 82e5319c394f7dba5ea0cb52a7cbf5a5f73036d9..dfd1f8aa33713fe5ef9be9cb0e54a248e5ad5c73 100644 (file)
@@ -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);
     }
 }
index c56c166959e5dec47bd1070dfca2078f45ddca1d..1a406f87c98f24f0965fe7c751e8a20e02af0598 100644 (file)
@@ -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");
     }
 }