From 18a764f6ec903997d97cf00f59f5203dc6f034dc Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Tue, 22 Jul 2008 10:46:29 +0000 Subject: [PATCH] 2008-07-22 Ramon Novoa * win32/modules/pandora_module.cc: Fixed a bug that made the agent crash when a module returned data of the wrong type. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@966 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_agents/ChangeLog | 5 ++++ .../win32/modules/pandora_module.cc | 27 ++++++++++++------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/pandora_agents/ChangeLog b/pandora_agents/ChangeLog index 90060f0a7d..8d5252baa8 100644 --- a/pandora_agents/ChangeLog +++ b/pandora_agents/ChangeLog @@ -1,3 +1,8 @@ +2008-07-22 Ramon Novoa + + * win32/modules/pandora_module.cc: Fixed a bug that made the agent + crash when a module returned data of the wrong type. + 2008-07-17 Manuel Arostegui * linux/pandora_agent.conf: Removed enabled debug by diff --git a/pandora_agents/win32/modules/pandora_module.cc b/pandora_agents/win32/modules/pandora_module.cc index ee43cbf70a..dbd897f645 100644 --- a/pandora_agents/win32/modules/pandora_module.cc +++ b/pandora_agents/win32/modules/pandora_module.cc @@ -350,10 +350,16 @@ Pandora_Module::getXml () { data = *iter; data_element = new TiXmlElement ("data"); element = new TiXmlElement ("value"); - data_clean = strreplace (this->getDataOutput (data), "%", "%%" ); - text = new TiXmlText (data_clean); - element->InsertEndChild (*text); - data_element->InsertEndChild (*element); + try { + data_clean = strreplace (this->getDataOutput (data), "%", "%%" ); + } catch (Output_Error e) { + delete element; + continue; + } + + text = new TiXmlText (data_clean); + element->InsertEndChild (*text); + data_element->InsertEndChild (*element); delete text; delete element; @@ -372,11 +378,14 @@ Pandora_Module::getXml () { } else { data = data_list->front (); element = new TiXmlElement ("data"); - data_clean = strreplace (this->getDataOutput (data), "%", "%%" ); - text = new TiXmlText (data_clean); - element->InsertEndChild (*text); - root->InsertEndChild (*element); - delete text; + try { + data_clean = strreplace (this->getDataOutput (data), "%", "%%" ); + text = new TiXmlText (data_clean); + element->InsertEndChild (*text); + root->InsertEndChild (*element); + delete text; + } catch (Output_Error e) { + } delete element; }