openpower-pels: json_utils: fix crash on invalid format string

The `getNumberString` function previously crashed if an invalid
format string was passed, because it would attempt to construct
a std::string from a nullptr.  There was even a test case that
confirmed that the code crashed via a SIGSEGV!

AddressSanitizer, which is ran on all of our meson-based CIs,
does not allow this kind of behavior.  Change `getNumberString`
so it throws a `std::invalid_argument` instead of crashing, which
itself might result in a `std::terminate` if the exception is
uncaught, but is at least acceptable behavior in the eyes of the
AddressSanitizer (and mine as well).

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I06d25edc2ddf552169383e03595426bb065425be
diff --git a/extensions/openpower-pels/json_utils.hpp b/extensions/openpower-pels/json_utils.hpp
index f6db297..6415c9e 100644
--- a/extensions/openpower-pels/json_utils.hpp
+++ b/extensions/openpower-pels/json_utils.hpp
@@ -71,10 +71,15 @@
     static_assert(std::is_integral<T>::value, "Integral required.");
 
     int len = asprintf(&value, format, number);
-    if (len)
+    if (len >= 0)
     {
         numString = value;
     }
+    else
+    {
+        throw std::invalid_argument(
+            std::string("getNumberString: invalid format string: ") + format);
+    }
     free(value);
 
     return numString;