chunks: fix memory error in Consumer::run

Change-Id: Ic137b88d4ab46ade788d2ae5c0aba59902167f7b
Refs: #3636
diff --git a/tools/chunks/catchunks/consumer.cpp b/tools/chunks/catchunks/consumer.cpp
index fe30f75..6ecd630 100644
--- a/tools/chunks/catchunks/consumer.cpp
+++ b/tools/chunks/catchunks/consumer.cpp
@@ -30,9 +30,8 @@
 namespace ndn {
 namespace chunks {
 
-Consumer::Consumer(Face& face, Validator& validator, bool isVerbose, std::ostream& os)
-  : m_face(face)
-  , m_validator(validator)
+Consumer::Consumer(Validator& validator, bool isVerbose, std::ostream& os)
+  : m_validator(validator)
   , m_outputStream(os)
   , m_nextToPrint(0)
   , m_isVerbose(isVerbose)
@@ -47,11 +46,9 @@
   m_nextToPrint = 0;
   m_bufferedData.clear();
 
-  discover->onDiscoverySuccess.connect(bind(&Consumer::startPipeline, this, _1));
-  discover->onDiscoveryFailure.connect(bind(&Consumer::onFailure, this, _1));
-  discover->run();
-
-  m_face.processEvents();
+  m_discover->onDiscoverySuccess.connect(bind(&Consumer::startPipeline, this, _1));
+  m_discover->onDiscoveryFailure.connect(bind(&Consumer::onFailure, this, _1));
+  m_discover->run();
 }
 
 void
diff --git a/tools/chunks/catchunks/consumer.hpp b/tools/chunks/catchunks/consumer.hpp
index e2451be..9996c14 100644
--- a/tools/chunks/catchunks/consumer.hpp
+++ b/tools/chunks/catchunks/consumer.hpp
@@ -59,7 +59,7 @@
   /**
    * @brief Create the consumer
    */
-  Consumer(Face& face, Validator& validator, bool isVerbose, std::ostream& os = std::cout);
+  Consumer(Validator& validator, bool isVerbose, std::ostream& os = std::cout);
 
   /**
    * @brief Run the consumer
@@ -85,7 +85,6 @@
   writeInOrderData();
 
 private:
-  Face& m_face;
   Validator& m_validator;
   std::ostream& m_outputStream;
   unique_ptr<DiscoverVersion> m_discover;
diff --git a/tools/chunks/catchunks/ndncatchunks.cpp b/tools/chunks/catchunks/ndncatchunks.cpp
index 98839b3..c877eaa 100644
--- a/tools/chunks/catchunks/ndncatchunks.cpp
+++ b/tools/chunks/catchunks/ndncatchunks.cpp
@@ -164,11 +164,12 @@
     }
 
     ValidatorNull validator;
-    Consumer consumer(face, validator, options.isVerbose);
+    Consumer consumer(validator, options.isVerbose);
 
     BOOST_ASSERT(discover != nullptr);
     BOOST_ASSERT(pipeline != nullptr);
     consumer.run(std::move(discover), std::move(pipeline));
+    face.processEvents();
   }
   catch (const Consumer::ApplicationNackError& e) {
     std::cerr << "ERROR: " << e.what() << std::endl;