diff --git a/gtsam/inference/LabeledSymbol.cpp b/gtsam/inference/LabeledSymbol.cpp index e6e6f3081..65a4ce416 100644 --- a/gtsam/inference/LabeledSymbol.cpp +++ b/gtsam/inference/LabeledSymbol.cpp @@ -71,9 +71,9 @@ void LabeledSymbol::print(const std::string& s) const { /* ************************************************************************* */ LabeledSymbol::operator std::string() const { - char buf[100]; - sprintf(buf, "%c%c%zu", c_, label_, j_); - return std::string(buf); + char buffer[100]; + snprintf(buffer, 100, "%c%c%llu", c_, label_, j_); + return std::string(buffer); } /* ************************************************************************* */ diff --git a/gtsam/inference/Symbol.cpp b/gtsam/inference/Symbol.cpp index 621587238..edaacb24b 100644 --- a/gtsam/inference/Symbol.cpp +++ b/gtsam/inference/Symbol.cpp @@ -22,6 +22,7 @@ #include #include #include +#include namespace gtsam { @@ -55,9 +56,9 @@ bool Symbol::equals(const Symbol& expected, double tol) const { } Symbol::operator std::string() const { - char buf[10]; - sprintf(buf, "%c%zu", c_, j_); - return std::string(buf); + char buffer[10]; + snprintf(buffer, 10, "%c%llu", c_, j_); + return std::string(buffer); } static Symbol make(gtsam::Key key) { return Symbol(key);}