From 8e21d3328f6b83a56ee5eed5710d433319a27280 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Tue, 19 Sep 2023 20:25:30 +0800 Subject: [PATCH] guid_to_string should be freed. --- bindings/guile/gnc-optiondb.i | 3 ++- libgnucash/backend/sql/gnc-owner-sql.cpp | 6 +++++- libgnucash/engine/gnc-option-impl.cpp | 7 ++++++- libgnucash/engine/gnc-option-impl.hpp | 4 +++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bindings/guile/gnc-optiondb.i b/bindings/guile/gnc-optiondb.i index 4e3874bc51..4b81198e0e 100644 --- a/bindings/guile/gnc-optiondb.i +++ b/bindings/guile/gnc-optiondb.i @@ -1226,9 +1226,10 @@ inline SCM return_scm_value(ValueType value) if (guid_list.empty()) return scm_simple_format(SCM_BOOL_F, list_format_str, scm_list_1(no_value)); SCM string_list{SCM_EOL}; + char guid_str[GUID_ENCODING_LENGTH+1]; for(auto guid : guid_list) { - auto guid_str{guid_to_string(&guid)}; + guid_to_string_buff (&guid, guid_str); auto guid_scm{scm_from_utf8_string(guid_str)}; string_list = scm_cons(guid_scm, string_list); } diff --git a/libgnucash/backend/sql/gnc-owner-sql.cpp b/libgnucash/backend/sql/gnc-owner-sql.cpp index 46b5ca360c..2a5e736c98 100644 --- a/libgnucash/backend/sql/gnc-owner-sql.cpp +++ b/libgnucash/backend/sql/gnc-owner-sql.cpp @@ -225,7 +225,11 @@ GncSqlColumnTableEntryImpl::add_to_query(QofIdTypeConst obj_name, buf.str(""); auto guid = qof_instance_get_guid(inst); if (guid != nullptr) - buf << guid_to_string(guid); + { + char strbuff[GUID_ENCODING_LENGTH+1]; + guid_to_string_buff (guid, strbuff); + buf << strbuff; + } else buf << "NULL"; vec.emplace_back(std::make_pair(guid_hdr, quote_string(buf.str()))); diff --git a/libgnucash/engine/gnc-option-impl.cpp b/libgnucash/engine/gnc-option-impl.cpp index b60b18a2ae..a2e7d05928 100644 --- a/libgnucash/engine/gnc-option-impl.cpp +++ b/libgnucash/engine/gnc-option-impl.cpp @@ -877,7 +877,12 @@ std::string GncOptionAccountSelValue::serialize() const noexcept { static const std::string no_value{"No Value"}; - return guid_equal(guid_null(), &m_value) ? no_value : guid_to_string(&m_value); + if (guid_equal(guid_null(), &m_value)) + return no_value; + + gchar strbuff[GUID_ENCODING_LENGTH + 1]; + guid_to_string_buff (&m_value, strbuff); + return strbuff; } bool diff --git a/libgnucash/engine/gnc-option-impl.hpp b/libgnucash/engine/gnc-option-impl.hpp index 4ebaa36708..ed4b8ad847 100644 --- a/libgnucash/engine/gnc-option-impl.hpp +++ b/libgnucash/engine/gnc-option-impl.hpp @@ -898,7 +898,9 @@ operator<< (std::ostream& oss, first = false; else oss << " "; - oss << guid_to_string(&value); + char strbuff[GUID_ENCODING_LENGTH+1]; + guid_to_string_buff (&value, strbuff); + oss << strbuff; } return oss; }