mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix dereference of expired temporaries.
Reported by clang 15.0.7, which will be in Ubuntu 23.04, -Wdangling-gsl
This commit is contained in:
parent
17e08d0f43
commit
6ba5bb326a
@ -261,13 +261,10 @@ equals_node_val_vs_kvp_frame (xmlNodePtr node, const KvpFrame* frm)
|
||||
}
|
||||
else
|
||||
{
|
||||
auto frm1str = g_strdup (frm->to_string ().c_str ());
|
||||
auto frm2str = g_strdup (cmpfrm->to_string ().c_str ());
|
||||
auto frmstr = frm->to_string ();
|
||||
auto cmpfrmstr = cmpfrm->to_string ();
|
||||
|
||||
printf ("%s vs %s\n", frm1str, frm2str);
|
||||
|
||||
g_free (frm1str);
|
||||
g_free (frm2str);
|
||||
printf ("%s vs %s\n", frmstr.c_str(), cmpfrmstr.c_str());
|
||||
|
||||
delete cmpfrm;
|
||||
return FALSE;
|
||||
|
@ -211,7 +211,10 @@ gchar *gnc_file_path_relative_part (const gchar *prefix, const gchar *path)
|
||||
{
|
||||
std::string p{path};
|
||||
if (p.find(prefix) == 0)
|
||||
return g_strdup(p.substr(strlen(prefix)).c_str());
|
||||
{
|
||||
auto str = p.substr(strlen(prefix));
|
||||
return g_strdup(str.c_str());
|
||||
}
|
||||
return g_strdup(path);
|
||||
}
|
||||
|
||||
|
@ -1101,7 +1101,8 @@ qof_strftime(gchar *buf, gsize max, const gchar *format, const struct tm *tm)
|
||||
gchar *
|
||||
gnc_date_timestamp (void)
|
||||
{
|
||||
return g_strdup(GncDateTime::timestamp().c_str());
|
||||
auto timestamp = GncDateTime::timestamp();
|
||||
return g_strdup(timestamp.c_str());
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
|
@ -65,10 +65,13 @@ header = N_("This Dataset contains features not supported "
|
||||
gchar *gnc_features_test_unknown (QofBook *book)
|
||||
{
|
||||
auto unknowns {qof_book_get_unknown_features (book, features_table)};
|
||||
if (unknowns.empty())
|
||||
return nullptr;
|
||||
|
||||
auto accum = [](const auto& a, const auto& b){ return a + "\n* " + b; };
|
||||
return unknowns.empty() ? nullptr :
|
||||
g_strdup (std::accumulate (unknowns.begin(), unknowns.end(),
|
||||
std::string (_(header)), accum).c_str());
|
||||
auto msg {std::accumulate (unknowns.begin(), unknowns.end(),
|
||||
std::string (_(header)), accum)};
|
||||
return g_strdup (msg.c_str());
|
||||
}
|
||||
|
||||
void gnc_features_set_used (QofBook *book, const gchar *feature)
|
||||
|
@ -459,7 +459,10 @@ GncOptionDB::save_to_kvp(QofBook* book, bool clear_options) const noexcept
|
||||
* have to store. */
|
||||
kvp = new KvpValue(option.template get_value<double>());
|
||||
else
|
||||
kvp = new KvpValue{g_strdup(option.template get_value<std::string>().c_str())};
|
||||
{
|
||||
auto str{option.template get_value<std::string>()};
|
||||
kvp = new KvpValue{g_strdup(str.c_str())};
|
||||
}
|
||||
qof_book_set_option(book, kvp, &list_head);
|
||||
}
|
||||
});
|
||||
|
@ -1102,8 +1102,8 @@ qof_instance_compare_kvp (const QofInstance *a, const QofInstance *b)
|
||||
char*
|
||||
qof_instance_kvp_as_string (const QofInstance *inst)
|
||||
{
|
||||
//The std::string is a local temporary and doesn't survive this function.
|
||||
return g_strdup(inst->kvp_data->to_string().c_str());
|
||||
auto str{inst->kvp_data->to_string()};
|
||||
return g_strdup(str.c_str());
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user