[gnumeric] be more careful in odf_write_comment



commit 13d2c86458c0cfd61516c76e746d7e6cb0114d13
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Fri May 27 17:13:17 2011 -0600

    be more careful in odf_write_comment
    
    2011-05-27  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-write.c (odf_write_comment): assume nothing

 plugins/openoffice/ChangeLog          |    4 ++++
 plugins/openoffice/openoffice-write.c |   27 ++++++++++++++++-----------
 2 files changed, 20 insertions(+), 11 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 1bf9930..c5263d0 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,9 @@
 2011-05-27  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-write.c (odf_write_comment): assume nothing
+
+2011-05-27  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-read.c (oo_rangeref_parse): handle foreign workbooks
 
 2011-05-27  Andreas J. Guelzow <aguelzow pyrshep ca>
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index a58791b..69f7d77 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -2512,9 +2512,9 @@ odf_cell_is_covered (Sheet const *sheet, GnmCell *current_cell,
 static void
 odf_write_comment (GnmOOExport *state, GnmComment const *cc)
 {
-	char const *author;
-	char const *text;
-	const PangoAttrList * markup;
+	char *author = NULL;
+	char *text = NULL;
+	const PangoAttrList * markup = NULL;
 	gboolean pp = TRUE;
 
 	g_object_get (G_OBJECT (state->xml), "pretty-print", &pp, NULL);
@@ -2527,16 +2527,21 @@ odf_write_comment (GnmOOExport *state, GnmComment const *cc)
 		gsf_xml_out_start_element (state->xml, DUBLINCORE "creator");
 		gsf_xml_out_add_cstr (state->xml, NULL, author);
 		gsf_xml_out_end_element (state->xml); /*  DUBLINCORE "creator" */;
+		g_free (author);
 	}
-	g_object_set (G_OBJECT (state->xml), "pretty-print", FALSE, NULL);
-	gsf_xml_out_start_element (state->xml, TEXT "p");
-	if (markup != NULL)
-		odf_new_markup (state, markup, text);
-	else {
-		gboolean white_written = TRUE;
-		odf_add_chars (state, text, strlen (text), &white_written);
+	if (text != NULL) {
+		g_object_set (G_OBJECT (state->xml), "pretty-print", FALSE, NULL);
+		gsf_xml_out_start_element (state->xml, TEXT "p");
+		if (markup != NULL) {
+			odf_new_markup (state, markup, text);
+			/* Are we leaking the markup? */
+		} else {
+			gboolean white_written = TRUE;
+			odf_add_chars (state, text, strlen (text), &white_written);
+		}
+		gsf_xml_out_end_element (state->xml);   /* p */
+		g_free (text);
 	}
-	gsf_xml_out_end_element (state->xml);   /* p */
 	g_object_set (G_OBJECT (state->xml), "pretty-print", pp, NULL);
 	gsf_xml_out_end_element (state->xml); /*  OFFICE "annotation" */
 }



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