From: John Darrington Date: Wed, 7 Jun 2017 08:44:37 +0000 (+0200) Subject: PsppireImportAssistant: Avoid possible null pointer dereferences X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bde6336e802bed3c7bdb2249d02f8d190025774f;p=pspp PsppireImportAssistant: Avoid possible null pointer dereferences --- diff --git a/src/ui/gui/psppire-import-assistant.c b/src/ui/gui/psppire-import-assistant.c index 49e075a297..bd69629d84 100644 --- a/src/ui/gui/psppire-import-assistant.c +++ b/src/ui/gui/psppire-import-assistant.c @@ -1214,16 +1214,18 @@ my_read (struct casereader *reader, void *aux, casenumber idx) const struct variable *var = dict_get_var (ia->dict, i); const gchar *ss = g_value_get_string (&value); - - union value *v = case_data_rw (c, var); - char *xx = data_in (ss_cstr (ss), - "UTF-8", - var_get_write_format (var)->type, - v, var_get_width (var), "UTF-8"); - - /* if (xx) */ - /* g_print ("%s:%d Err %s\n", __FILE__, __LINE__, xx); */ - free (xx); + if (ss) + { + union value *v = case_data_rw (c, var); + char *xx = data_in (ss_cstr (ss), + "UTF-8", + var_get_write_format (var)->type, + v, var_get_width (var), "UTF-8"); + + /* if (xx) */ + /* g_print ("%s:%d Err %s\n", __FILE__, __LINE__, xx); */ + free (xx); + } g_value_unset (&value); } } @@ -1307,7 +1309,8 @@ prepare_formats_page (PsppireImportAssistant *ia) { gchar *s = NULL; gtk_tree_model_get (ia->delimiters_model, &iter, i+1, &s, -1); - fmt_guesser_add (fg[i], ss_cstr (s)); + if (s) + fmt_guesser_add (fg[i], ss_cstr (s)); free (s); } }