mgmt: fix ndns-add-rr-from-file segfaults when input file cannot be
loaded
refs #2257
Change-Id: I263a0794f3b351954ceabe25db959dd350500c18
diff --git a/src/mgmt/management-tool.cpp b/src/mgmt/management-tool.cpp
index 10e8aae..9925aca 100644
--- a/src/mgmt/management-tool.cpp
+++ b/src/mgmt/management-tool.cpp
@@ -334,6 +334,10 @@
else
data = ndn::io::load<ndn::Data>(inFile);
+ if (data == nullptr) {
+ throw Error("input does not contain a valid Data packet (is it in base64 format?)");
+ }
+
//determine whether the data is a self-signed certificate
shared_ptr<Regex> regex1 = make_shared<Regex>("(<>*)<KEY>(<>+)<ID-CERT><>");
if (regex1->match(data->getName())) {