qof_instance_get gchar* must be freed

A call to qof_instance_get expecting a gchar* receives a newly
allocated string which must be freed.
This commit is contained in:
Christopher Lam 2021-08-13 23:33:03 +08:00
parent e4d808e674
commit 6bf5a618de
3 changed files with 17 additions and 15 deletions

View File

@ -1866,9 +1866,10 @@ account_cell_property_data_func (GtkTreeViewColumn *tree_column,
account = gnc_tree_view_account_get_account_from_iter(s_model, s_iter);
qof_instance_get (QOF_INSTANCE (account), key, &string, NULL);
if (string == NULL)
string = "";
string = g_strdup ("");
g_object_set (G_OBJECT (cell), "text", string, "xalign", 0.0, NULL);
g_free (string);
view = g_object_get_data(G_OBJECT(tree_column), "tree-view");

View File

@ -1965,13 +1965,16 @@ gnc_plugin_page_report_exportpdf_cb( GtkAction *action, GncPluginPageReport *rep
// Yes. In the kvp, look up the key for the Export-PDF output
// directory. If it exists, prepend this to the job name so that
// we can export to PDF.
if (dirname && g_file_test(dirname,
G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
{
gchar *tmp = g_build_filename(dirname, job_name, NULL);
g_free(job_name);
job_name = tmp;
}
if (dirname)
{
if (g_file_test (dirname, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
{
gchar *tmp = g_build_filename (dirname, job_name, NULL);
g_free (job_name);
job_name = tmp;
}
g_free (dirname);
}
}
}

View File

@ -1032,13 +1032,11 @@ qof_book_get_default_gain_loss_acct_guid (QofBook *book)
gboolean
qof_book_use_trading_accounts (const QofBook *book)
{
const char *opt = NULL;
qof_instance_get (QOF_INSTANCE (book),
"trading-accts", &opt,
NULL);
if (opt && opt[0] == 't' && opt[1] == 0)
return TRUE;
return FALSE;
char *opt = nullptr;
qof_instance_get (QOF_INSTANCE (book), "trading-accts", &opt, nullptr);
auto retval = (opt && opt[0] == 't' && opt[1] == 0);
g_free (opt);
return retval;
}
/* Returns TRUE if this book uses split action field as the 'Num' field, FALSE