[libgda/LIBGDA_4.2] GdaDataModel: crasher correction



commit 714d01c6b2208e40bafc5a176f1f67085ab39641
Author: Vivien Malerba <malerba gnome-db org>
Date:   Sun Aug 28 21:40:09 2011 +0200

    GdaDataModel: crasher correction

 libgda/gda-data-model.c |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)
---
diff --git a/libgda/gda-data-model.c b/libgda/gda-data-model.c
index 17acb03..dbea330 100644
--- a/libgda/gda-data-model.c
+++ b/libgda/gda-data-model.c
@@ -1448,18 +1448,30 @@ export_to_text_separated (GdaDataModel *model, const gint *cols, gint nb_cols,
 				txt = g_strdup ("");
 			else {
 				gchar *tmp;
-				gsize len, size;
 				
 				tmp = gda_value_stringify (value);
-				len = strlen (tmp);
-				size = 2 * len + 3;
-				txt = g_new (gchar, size);
-
-				len = csv_write2 (txt, size, tmp, len, quote);
-				txt [len] = 0;
-				if (!field_quotes) {
-					txt [len - 1] = 0;
-					memmove (txt, txt+1, len);
+				if (tmp) {
+					gsize len, size;
+					len = strlen (tmp);
+					size = 2 * len + 3;
+					txt = g_new (gchar, size);
+
+					len = csv_write2 (txt, size, tmp, len, quote);
+					txt [len] = 0;
+					if (!field_quotes) {
+						txt [len - 1] = 0;
+						memmove (txt, txt+1, len);
+					}
+				}
+				else {
+					if (field_quotes) {
+						txt = g_new (gchar, 3);
+						txt [0] = quote;
+						txt [1] = quote;
+						txt [2] = 0;
+					}
+					else
+						txt = g_strdup ("");
 				}
 			}
 			if (c > 0)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]