[gnumeric] Fixed crash on interprocess image copying. [#687414]



commit c7897437aeddbca8df15f07704a0f6a81bb0ce22
Author: Jean Brefort <jean brefort normalesup org>
Date:   Fri Nov 2 09:28:46 2012 +0100

    Fixed crash on interprocess image copying. [#687414]

 ChangeLog                |    5 +++++
 NEWS                     |    1 +
 src/sheet-object-image.c |   10 +++++++++-
 3 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1e53d32..d4c6760 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-11-02  Jean Brefort  <jean brefort normalesup org>
+
+	* src/sheet-object-image.c (gnm_soi_write_xml_sax): fixed crash when
+	copying an image from one process to another. [#687414]
+
 2012-10-30  Jean Brefort  <jean brefort normalesup org>
 
 	* src/graph.c (gnm_go_data_vector_load_values),
diff --git a/NEWS b/NEWS
index c19abb6..43a9a0d 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Andreas:
 Jean:
 	* Fixed indentation in cell format dialog. [#683576]
 	* Do not use filtered out values in graphs. [#687209]
+	* Fixed crash on interprocess image copying. [#687414]
 
 Morten:
 	* Fix xlsx save performance problems.  [#662058]  [#685530]
diff --git a/src/sheet-object-image.c b/src/sheet-object-image.c
index 3037fe1..80f73a1 100644
--- a/src/sheet-object-image.c
+++ b/src/sheet-object-image.c
@@ -441,7 +441,15 @@ gnm_soi_write_xml_sax (SheetObject const *so, GsfXMLOut *output,
 		gsf_xml_out_add_cstr (output, "image-type", soi->type);
 	if (soi->image && go_image_get_name (soi->image)) {
 		gsf_xml_out_add_cstr (output, "name", go_image_get_name (soi->image));
-		go_doc_save_image (GO_DOC (sheet_object_get_sheet (so)->workbook), go_image_get_name (soi->image));
+		if (sheet_object_get_sheet (so))
+			go_doc_save_image (GO_DOC (sheet_object_get_sheet (so)->workbook), go_image_get_name (soi->image));
+		else {
+			/* looks that this may happen when pasting from another process, see #687414 */
+			gsize length;
+			guint8 const *data = go_image_get_data (soi->image, &length);
+			gsf_xml_out_add_uint (output, "size-bytes", length);
+			gsf_xml_out_add_base64 (output, NULL, data, length);
+		}
 	} else {
 		gsf_xml_out_add_uint (output, "size-bytes", soi->bytes.len);
 		gsf_xml_out_add_base64 (output, NULL, soi->bytes.data, soi->bytes.len);



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