From 280ea9dc419bc28bce42a0e4799ad8ab27530ea4 Mon Sep 17 00:00:00 2001 From: Eduardo Ramos Testillano Date: Mon, 20 Jun 2016 03:33:43 +0200 Subject: [PATCH] fix, to avoid continuing working over object --- example/diameter/batchConverter/main.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/example/diameter/batchConverter/main.cpp b/example/diameter/batchConverter/main.cpp index 85f7948..ae2ffdc 100644 --- a/example/diameter/batchConverter/main.cpp +++ b/example/diameter/batchConverter/main.cpp @@ -68,14 +68,17 @@ void _exit(const std::string &message, int resultCode = 1) { } // Decodes a diameter message coming from a datablock -void decodeDataBlock(const anna::DataBlock &db/*, unsigned int & detectedApplicationId*/) throw() { +bool decodeDataBlock(const anna::DataBlock &db/*, unsigned int & detectedApplicationId*/) throw() { try { G_codecMsg.clear(); G_codecMsg.decode(db); } catch(RuntimeException &ex) { std::cerr << ex.asString() << std::endl << std::endl; //_exit(ex.asString()); + return false; } + + return true; } //------------------------------------------------------------------- @@ -203,15 +206,16 @@ int main(int argc, char **argv) { _exit("Error reading hex file provided"); // Decode datablock: - decodeDataBlock(db_aux); + if (decodeDataBlock(db_aux)) { - // Write conversion: - std::string outputFile = entry + ".as.xml"; - std::ofstream out(outputFile.c_str(), std::ifstream::out); - out << G_codecMsg.asXMLString(); - out.close(); + // Write conversion: + std::string outputFile = entry + ".as.xml"; + std::ofstream out(outputFile.c_str(), std::ifstream::out); + out << G_codecMsg.asXMLString(); + out.close(); - anyHexConverted = true; + anyHexConverted = true; + } } } -- 2.20.1