name: fix Component wireDecode logic error
Change-Id: Ie1c79dc256af0920f8f8ba58d6f69b0ba71a9791
Refs: #2227
diff --git a/src/name-component.cpp b/src/name-component.cpp
index 8aad977..8d2db29 100644
--- a/src/name-component.cpp
+++ b/src/name-component.cpp
@@ -58,7 +58,7 @@
Component::Component(const Block& wire)
: Block(wire)
{
- if (type() != tlv::NameComponent && type() != tlv::ImplicitSha256DigestComponent)
+ if (!isGeneric() && !isImplicitSha256Digest())
throw Error("Cannot construct name::Component from not a NameComponent "
"or ImplicitSha256DigestComponent TLV wire block");
}
@@ -475,11 +475,8 @@
void
Component::wireDecode(const Block& wire)
{
- if (wire.type() != tlv::NameComponent || wire.type() != tlv::ImplicitSha256DigestComponent)
- throw Error("name::Component::wireDecode called on not a NameComponent "
- "or ImplicitSha256DigestComponent TLV wire block");
-
*this = wire;
+ // validity check is done within Component(const Block& wire)
}
} // namespace name