Fix double free issue with global+static variable
Setting defaultConfigPaths as constexpr and std::array allow it to be
destructed cleaning with no issue. Without this the ipmid will triggered
double free error on cleanups.
Change-Id: I689ce51ecb9a051891e31c50d44d15d74add47ab
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/bmc/buildjson.cpp b/bmc/buildjson.cpp
index 21a48f3..61a97b7 100644
--- a/bmc/buildjson.cpp
+++ b/bmc/buildjson.cpp
@@ -26,7 +26,6 @@
#include <exception>
#include <fstream>
#include <string>
-#include <vector>
namespace ipmi_flash
{
@@ -68,9 +67,4 @@
unit, systemdMode);
}
-const std::vector<const char*> defaultConfigPaths = {
- "/usr/share/phosphor-ipmi-flash",
- "/run/phosphor-ipmi-flash",
-};
-
} // namespace ipmi_flash
diff --git a/bmc/buildjson.hpp b/bmc/buildjson.hpp
index 58266b5..d8f8c80 100644
--- a/bmc/buildjson.hpp
+++ b/bmc/buildjson.hpp
@@ -6,6 +6,7 @@
#include <nlohmann/json.hpp>
+#include <array>
#include <memory>
#include <string>
#include <vector>
@@ -24,7 +25,10 @@
std::unique_ptr<TriggerableActionInterface>
buildSystemd(const nlohmann::json& data);
-extern const std::vector<const char*> defaultConfigPaths;
+constexpr std::array defaultConfigPaths = {
+ "/usr/share/phosphor-ipmi-flash",
+ "/run/phosphor-ipmi-flash",
+};
/* HandlersBuilderIfc is a helper class that builds Handlers from the json files
* found within a specified directory.