gnucash maint: xxxgtk_textview_get_text returns a char* which must be freed, redux
Christopher Lam
clam at code.gnucash.org
Tue Oct 18 09:50:05 EDT 2022
Updated via https://github.com/Gnucash/gnucash/commit/9a141a8c (commit)
from https://github.com/Gnucash/gnucash/commit/8f1794cb (commit)
commit 9a141a8c761b797d2643ff3f0e984bbb4f076721
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Tue Oct 18 21:39:34 2022 +0800
xxxgtk_textview_get_text returns a char* which must be freed, redux
xxxgtk_textview_get_text may return "" whose strlen is zero, and the
previous code would fail to free it. reword this code to ensure it is
freed appropriately.
diff --git a/gnucash/gnome/gnc-plugin-page-budget.c b/gnucash/gnome/gnc-plugin-page-budget.c
index a6c1034ab..6a873cf84 100644
--- a/gnucash/gnome/gnc-plugin-page-budget.c
+++ b/gnucash/gnome/gnc-plugin-page-budget.c
@@ -1297,9 +1297,8 @@ gnc_plugin_page_budget_cmd_budget_note(GtkAction *action,
{
case GTK_RESPONSE_OK:
txt = xxxgtk_textview_get_text(GTK_TEXT_VIEW(note));
- if (!strlen(txt))
- txt = NULL;
- gnc_budget_set_account_period_note(priv->budget, acc, period_num, txt);
+ gnc_budget_set_account_period_note (priv->budget, acc, period_num,
+ (txt && *txt) ? txt : NULL);
g_free (txt);
break;
default:
Summary of changes:
gnucash/gnome/gnc-plugin-page-budget.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
More information about the gnucash-changes
mailing list