diff --git a/src/lib/dns/rdata/generic/tkey_249.cc b/src/lib/dns/rdata/generic/tkey_249.cc index 886eb40375..435a345ac5 100644 --- a/src/lib/dns/rdata/generic/tkey_249.cc +++ b/src/lib/dns/rdata/generic/tkey_249.cc @@ -69,10 +69,15 @@ struct TKEYImpl { const void* key, size_t other_len, const void* other_data) : algorithm_(algorithm), inception_(inception), expire_(expire), mode_(mode), error_(error), - key_(static_cast(key), - static_cast(key) + key_len), - other_data_(static_cast(other_data), - static_cast(other_data) + other_len) + key_(key_len > 0 ? + vector(static_cast(key), + static_cast(key) + key_len) : + vector(key_len)), + other_data_(other_len > 0 ? + vector(static_cast(other_data), + static_cast(other_data) + + other_len) : + vector(other_len)) {} /// \brief Common part of toWire methods. diff --git a/src/lib/dns/rdataclass.cc b/src/lib/dns/rdataclass.cc index 3a3de4aa33..3cb61ade93 100644 --- a/src/lib/dns/rdataclass.cc +++ b/src/lib/dns/rdataclass.cc @@ -5217,10 +5217,15 @@ struct TKEYImpl { const void* key, size_t other_len, const void* other_data) : algorithm_(algorithm), inception_(inception), expire_(expire), mode_(mode), error_(error), - key_(static_cast(key), - static_cast(key) + key_len), - other_data_(static_cast(other_data), - static_cast(other_data) + other_len) + key_(key_len > 0 ? + vector(static_cast(key), + static_cast(key) + key_len) : + vector(key_len)), + other_data_(other_len > 0 ? + vector(static_cast(other_data), + static_cast(other_data) + + other_len) : + vector(other_len)) {} /// \brief Common part of toWire methods.