monitor: fix undefined behavior

A recent static analysis check revealed a use-after-free condition in
json_parser.cpp. This fixes the undefined behavior.

Signed-off-by: Mike Capps <mikepcapps@gmail.com>
Change-Id: I62b82b4982386d14e6ee7225b3ab6f3628e2a416
diff --git a/monitor/json_parser.cpp b/monitor/json_parser.cpp
index 1c537e9..a46e2a9 100644
--- a/monitor/json_parser.cpp
+++ b/monitor/json_parser.cpp
@@ -200,13 +200,12 @@
         auto deviation = fan["deviation"].get<size_t>();
         if (deviation < 0 || 100 < deviation)
         {
-            auto msg =
-                fmt::format(
-                    "Invalid deviation of {} found, must be between 0 and 100",
-                    deviation)
-                    .c_str();
-            log<level::ERR>(msg);
-            throw std::runtime_error(msg);
+            auto msg = fmt::format(
+                "Invalid deviation of {} found, must be between 0 and 100",
+                deviation);
+
+            log<level::ERR>(msg.c_str());
+            throw std::runtime_error(msg.c_str());
         }
 
         // Construct the sensor definitions for this fan