gnucash maint: Bug 759674 - GNUCash crashes when importing invoices or bills with delimited import
Mike Evans
mikee at code.gnucash.org
Mon Dec 21 06:58:39 EST 2015
Updated via https://github.com/Gnucash/gnucash/commit/5370124d (commit)
from https://github.com/Gnucash/gnucash/commit/a1c7f645 (commit)
commit 5370124dc1368ebe19924a04b4f08e0c174c8dd7
Author: Mike Evans <mikee at saxicola.co.uk>
Date: Sun Dec 20 13:16:54 2015 +0000
Bug 759674 - GNUCash crashes when importing invoices or bills with delimited import
Make sure all instances of gchar* have *some* value, ie NULL, else undefined behavior occurs
when free is called on those objects.
diff --git a/src/plugins/bi_import/dialog-bi-import-gui.c b/src/plugins/bi_import/dialog-bi-import-gui.c
index c9a3b8f..882a26a 100644
--- a/src/plugins/bi_import/dialog-bi-import-gui.c
+++ b/src/plugins/bi_import/dialog-bi-import-gui.c
@@ -75,7 +75,7 @@ void gnc_import_gui_type_cb (GtkWidget *widget, gpointer data);
// utils
static gchar *gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *default_input);
static void gnc_info2_dialog (GtkWidget *parent, const gchar *title, const gchar *msg);
-
+static QofLogModule log_module = G_LOG_DOMAIN; //G_LOG_BUSINESS;
BillImportGui *
gnc_plugin_bi_import_showGUI(void)
@@ -167,7 +167,7 @@ static gchar *
gnc_plugin_bi_import_getFilename(void)
{
// prepare file import dialog
- gchar *filename;
+ gchar *filename = NULL;
GList *filters;
GtkFileFilter *filter;
filters = NULL;
@@ -264,7 +264,7 @@ gnc_bi_import_gui_destroy_cb (GtkWidget *widget, gpointer data)
void gnc_bi_import_gui_buttonOpen_cb (GtkWidget *widget, gpointer data)
{
- gchar *filename;
+ gchar *filename = NULL;
BillImportGui *gui = data;
filename = gnc_plugin_bi_import_getFilename();
@@ -328,7 +328,7 @@ void gnc_bi_import_gui_option4_cb (GtkWidget *widget, gpointer data)
void gnc_bi_import_gui_option5_cb (GtkWidget *widget, gpointer data)
{
BillImportGui *gui = data;
- gchar *temp;
+ gchar *temp = NULL;
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
return;
temp = gnc_input_dialog (0, _("Adjust regular expression used for import"), _("This regular expression is used to parse the import file. Modify according to your needs.\n"), gui->regexp->str);
@@ -343,7 +343,7 @@ void gnc_bi_import_gui_option5_cb (GtkWidget *widget, gpointer data)
void gnc_bi_import_gui_open_mode_cb (GtkWidget *widget, gpointer data)
{
BillImportGui *gui = data;
- const gchar *name;
+ const gchar *name = NULL;
name = gtk_buildable_get_name(GTK_BUILDABLE(widget));
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
return;
@@ -359,7 +359,7 @@ void gnc_bi_import_gui_open_mode_cb (GtkWidget *widget, gpointer data)
void gnc_import_gui_type_cb (GtkWidget *widget, gpointer data)
{
BillImportGui *gui = data;
- const gchar *name;
+ const gchar *name = NULL;
name = gtk_buildable_get_name(GTK_BUILDABLE(widget));
if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) ))
return;
@@ -391,7 +391,7 @@ gnc_input_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const
gint result;
GtkWidget *view;
GtkTextBuffer *buffer;
- gchar *user_input;
+ gchar *user_input = NULL;
GtkTextIter start, end;
/* Create the widgets */
diff --git a/src/plugins/bi_import/dialog-bi-import.c b/src/plugins/bi_import/dialog-bi-import.c
index ec11ace..a67d255 100644
--- a/src/plugins/bi_import/dialog-bi-import.c
+++ b/src/plugins/bi_import/dialog-bi-import.c
@@ -90,8 +90,9 @@ gnc_bi_import_read_file (const gchar * filename, const gchar * parser_regexp,
FILE *f;
// regexp
- char *line;
- gchar *line_utf8, *temp;
+ char *line = NULL;
+ gchar *line_utf8 = NULL;
+ gchar *temp = NULL;
GMatchInfo *match_info;
GError *err;
GRegex *regexpat;
@@ -233,7 +234,8 @@ gnc_bi_import_fix_bis (GtkListStore * store, guint * fixed, guint * deleted,
{
GtkTreeIter iter;
gboolean valid, row_deleted, row_fixed;
- gchar *id, *date_opened, *date_posted, *due_date, *owner_id, *date, *quantity, *price;
+ gchar *id = NULL, *date_opened = NULL, *date_posted = NULL, *due_date = NULL,
+ *owner_id = NULL, *date = NULL, *quantity = NULL, *price = NULL;
GString *prev_id, *prev_date_opened, *prev_date_posted, *prev_owner_id, *prev_date; // needed to fix multi line invoices
guint dummy;
gint row = 1;
@@ -511,11 +513,12 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
{
gboolean valid;
GtkTreeIter iter;
- gchar *id, *date_opened, *owner_id, *billing_id, *notes;
- gchar *date, *desc, *action, *account, *quantity, *price, *disc_type,
- *disc_how, *discount, *taxable, *taxincluded, *tax_table;
- gchar *date_posted, *due_date, *account_posted, *memo_posted,
- *accumulatesplits;
+ gchar *id = NULL, *date_opened = NULL, *owner_id = NULL, *billing_id = NULL, *notes = NULL;
+ gchar *date = NULL, *desc = NULL, *action = NULL, *account = NULL, *quantity = NULL,
+ *price = NULL, *disc_type = NULL, *disc_how = NULL, *discount = NULL, *taxable = NULL,
+ *taxincluded = NULL, *tax_table = NULL;
+ gchar *date_posted = NULL, *due_date = NULL, *account_posted = NULL, *memo_posted = NULL,
+ *accumulatesplits = NULL;
guint dummy;
GncInvoice *invoice;
GncEntry *entry;
Summary of changes:
src/plugins/bi_import/dialog-bi-import-gui.c | 14 +++++++-------
src/plugins/bi_import/dialog-bi-import.c | 19 +++++++++++--------
2 files changed, 18 insertions(+), 15 deletions(-)
More information about the gnucash-changes
mailing list