From e90fb3d8f7e2989e6315afc1c8d97af5319725ba Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Fri, 1 Sep 2017 15:00:21 +0200 Subject: [PATCH] Catch Pandora_Wmi::Pandora_Wmi_Exception exceptions. Fixes #89. --- .../win32/modules/pandora_module_factory.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pandora_agents/win32/modules/pandora_module_factory.cc b/pandora_agents/win32/modules/pandora_module_factory.cc index 23ebaaf7e8..db33c1315a 100644 --- a/pandora_agents/win32/modules/pandora_module_factory.cc +++ b/pandora_agents/win32/modules/pandora_module_factory.cc @@ -1139,11 +1139,14 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { module = new Pandora_Module_Freedisk_Percent (module_name, module_freedisk_percent); // Added a description with the memory free - char buffer[100]; - unsigned long memory = Pandora_Wmi::getDiskFreeSpace(module_freedisk_percent); - if (sprintf(buffer, "Free memory %s %dMB", + try { + char buffer[100]; + unsigned long memory = Pandora_Wmi::getDiskFreeSpace(module_freedisk_percent); + if (sprintf(buffer, "Free memory %s %dMB", module_freedisk_percent.c_str(), memory) > 0) { - module->setDescription(buffer); + module->setDescription(buffer); + } + } catch (Pandora_Wmi::Pandora_Wmi_Exception e) { } } else if (module_freememory != "") { module = new Pandora_Module_Freememory (module_name);