From 3c469b3133e92d19384b3430c824528f2bf6bd92 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Sat, 30 Jul 2022 15:51:33 -0400 Subject: [PATCH] Avoid treating simple strings as format strings --- include/cantera/base/AnyMap.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/cantera/base/AnyMap.h b/include/cantera/base/AnyMap.h index e182fa838..b20045fd8 100644 --- a/include/cantera/base/AnyMap.h +++ b/include/cantera/base/AnyMap.h @@ -709,8 +709,9 @@ public: const std::string& message, const Args&... args) : CanteraError( procedure, - formatError(fmt::format(message, args...), - node.m_line, node.m_column, node.m_metadata)) + formatError( + (sizeof...(args) == 0) ? message : fmt::format(message, args...), + node.m_line, node.m_column, node.m_metadata)) { } @@ -723,13 +724,13 @@ public: const Args&... args) : CanteraError( procedure, - formatError2(fmt::format(message, args...), - node1.m_line, node1.m_column, node1.m_metadata, - node2.m_line, node2.m_column, node2.m_metadata)) + formatError2( + (sizeof...(args) == 0) ? message : fmt::format(message, args...), + node1.m_line, node1.m_column, node1.m_metadata, + node2.m_line, node2.m_column, node2.m_metadata)) { } - virtual std::string getClass() const { return "InputFileError"; }