util/io: catch invalid_argument generated by trying to load empty file

refs: #4434

Change-Id: I884a5fba25fc5140ef00b492ba655aac87600426
diff --git a/src/util/io.cpp b/src/util/io.cpp
index 76fe18c..3a39bd0 100644
--- a/src/util/io.cpp
+++ b/src/util/io.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -57,6 +57,9 @@
   catch (const tlv::Error&) {
     return nullopt;
   }
+  catch (const std::invalid_argument&) {
+    return nullopt;
+  }
 }
 
 void
diff --git a/tests/unit-tests/util/io.t.cpp b/tests/unit-tests/util/io.t.cpp
index b2ec66b..1b46bca 100644
--- a/tests/unit-tests/util/io.t.cpp
+++ b/tests/unit-tests/util/io.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -275,6 +275,10 @@
 
   BOOST_REQUIRE(readCert != nullptr);
   BOOST_CHECK_EQUAL(cert.getName(), readCert->getName());
+
+  this->writeFile<std::string>("");
+  readCert = io::load<security::v2::Certificate>(filename);
+  BOOST_REQUIRE(readCert == nullptr);
 }
 
 BOOST_AUTO_TEST_SUITE_END() // TestIo