diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index cd92c80..5752fb7 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -2824,6 +2824,16 @@ odf_z_idx_compare (gconstpointer a, gconstpointer b)
 }
 
 static void
+odf_destroy_object_offset (gpointer data)
+{
+	object_offset_t *ob_off = data;
+
+	g_free (ob_off->control);
+	g_object_unref (ob_off->so);
+	g_free (ob_off);
+}
+
+static void
 odf_complete_control_setup (OOParseState *state, object_offset_t const *ob_off)
 {
 	OOControl *oc = g_hash_table_lookup (state->controls, ob_off->control);
@@ -11836,6 +11846,7 @@ openoffice_file_open (G_GNUC_UNUSED GOFileOpener const *fo, GOIOContext *io_cont
 	OOParseState	 state;
 	GError		*err = NULL;
 	int i;
+	gboolean         content_malformed = FALSE;
 
 	zip = gsf_infile_zip_new (input, &err);
 	if (zip == NULL) {
@@ -12004,7 +12015,7 @@ openoffice_file_open (G_GNUC_UNUSED GOFileOpener const *fo, GOIOContext *io_cont
 			err = gsf_doc_meta_data_read_from_odf (meta_data, meta_file);
 			if (NULL != err) {
 				go_io_warning (io_context,
-					_("Invalid metadata '%s'"), err->message);
+					       _("Invalid metadata '%s'"), err->message);
 				g_error_free (err);
 			} else
 				go_doc_set_meta_data (GO_DOC (state.pos.wb), meta_data);
@@ -12027,58 +12038,60 @@ openoffice_file_open (G_GNUC_UNUSED GOFileOpener const *fo, GOIOContext *io_cont
 				   ? ooo1_content_dtd
 				   : opendoc_content_dtd,
 				   gsf_odf_get_ns ());
-	if (gsf_xml_in_doc_parse (doc, contents, &state)) {
-		GsfInput *settings;
-		char const *filesaver;
-
-		/* get the sheet in the right order (in case something was
-		 * created out of order implictly) */
-		state.sheet_order = g_slist_reverse (state.sheet_order);
-
-		if (g_slist_length (state.sheet_order) < (guint) workbook_sheet_count (state.pos.wb)) {
-			/* We have seen instances of ODF files generated by   */
-			/* Libreoffice referring internally to table included */
-			/* inside charts. Those tables defacto don't exist    */
-			/* but we have to assume their existence to resolve   */
-			/* the references. We need to delete tehm now. See    */
-			/* https://bugzilla.gnome.org/show_bug.cgi?id=698388  */
-			GSList *to_be_deleted = NULL;
-			GSList *l;
+	content_malformed = !gsf_xml_in_doc_parse (doc, contents, &state);
+
+	/* get the sheet in the right order (in case something was
+	 * created out of order implictly) */
+	state.sheet_order = g_slist_reverse (state.sheet_order);
+
+	if (g_slist_length (state.sheet_order) < (guint) workbook_sheet_count (state.pos.wb)) {
+		/* We have seen instances of ODF files generated by   */
+		/* Libreoffice referring internally to table included */
+		/* inside charts. Those tables defacto don't exist    */
+		/* but we have to assume their existence to resolve   */
+		/* the references. We need to delete them now. See    */
+		/* https://bugzilla.gnome.org/show_bug.cgi?id=698388  */
+		GSList *to_be_deleted = NULL;
+		GSList *l;
 
-			WORKBOOK_FOREACH_SHEET
-				(state.pos.wb, sheet,
-				 {
-					 if (NULL == g_slist_find (state.sheet_order, sheet))
-						 to_be_deleted = g_slist_prepend (to_be_deleted, sheet);	 
-				 });
-			l = to_be_deleted;
-			while (l) {
-				workbook_sheet_delete (l->data);
-				l = l->next;
-			}
-			g_slist_free (to_be_deleted);
+		WORKBOOK_FOREACH_SHEET
+			(state.pos.wb, sheet,
+			 {
+				 if (NULL == g_slist_find (state.sheet_order, sheet))
+					 to_be_deleted = g_slist_prepend (to_be_deleted, sheet);	 
+			 });
+		l = to_be_deleted;
+		while (l) {
+			workbook_sheet_delete (l->data);
+			l = l->next;
 		}
+		g_slist_free (to_be_deleted);
+	}
 
-		if (state.debug) {
-			GSList *l, *sheets;
-			g_printerr ("Order we desire:\n");
-			for (l = state.sheet_order; l; l = l->next) {
-				Sheet *sheet = l->data;
-				g_printerr ("Sheet %s\n", sheet->name_unquoted);
-			}
-			g_printerr ("Order we have:\n");
-			sheets = workbook_sheets (state.pos.wb);
-			for (l = sheets; l; l = l->next) {
-				Sheet *sheet = l->data;
-				g_printerr ("Sheet %s\n", sheet->name_unquoted);
-			}
-			g_slist_free (sheets);
+	if (state.debug) {
+		GSList *l, *sheets;
+		g_printerr ("Order we desire:\n");
+		for (l = state.sheet_order; l; l = l->next) {
+			Sheet *sheet = l->data;
+			g_printerr ("Sheet %s\n", sheet->name_unquoted);
+		}
+		g_printerr ("Order we have:\n");
+		sheets = workbook_sheets (state.pos.wb);
+		for (l = sheets; l; l = l->next) {
+			Sheet *sheet = l->data;
+			g_printerr ("Sheet %s\n", sheet->name_unquoted);
 		}
+		g_slist_free (sheets);
+	}
+
+	workbook_sheet_reorder (state.pos.wb, state.sheet_order);
+	g_slist_free (state.sheet_order);
 
-		workbook_sheet_reorder (state.pos.wb, state.sheet_order);
-		g_slist_free (state.sheet_order);
+	odf_fix_expr_names (&state);
 
-		odf_fix_expr_names (&state);
+	if (!content_malformed) {
+		GsfInput *settings;
+		char const *filesaver;
 
 		/* look for the view settings */
 		state.settings.settings
@@ -12122,8 +12135,8 @@ openoffice_file_open (G_GNUC_UNUSED GOFileOpener const *fo, GOIOContext *io_cont
 
 		g_hash_table_destroy (state.settings.settings);
 		state.settings.settings = NULL;
-	} else
-		go_io_error_string (io_context, _("XML document not well formed!"));
+	}
+
 	gsf_xml_in_doc_free (doc);
 	odf_clear_conventions (&state);
 
@@ -12163,9 +12176,10 @@ openoffice_file_open (G_GNUC_UNUSED GOFileOpener const *fo, GOIOContext *io_cont
 	g_free (state.chart.cs_modifiers);
 	g_free (state.chart.cs_viewbox);
 	g_free (state.chart.cs_type);
+	if (state.chart_list)
+		g_slist_free_full (state.chart_list, odf_destroy_object_offset);
 	if (state.chart.cs_variables)
 		g_hash_table_destroy (state.chart.cs_variables);
-
 	g_slist_free_full (state.text_p_for_cell.span_style_stack, g_free);
 	if (state.text_p_for_cell.gstr)
 		g_string_free (state.text_p_for_cell.gstr, TRUE);
@@ -12174,6 +12188,9 @@ openoffice_file_open (G_GNUC_UNUSED GOFileOpener const *fo, GOIOContext *io_cont
 
 	g_object_unref (zip);
 
+	if (content_malformed) 
+		go_io_error_string (io_context, _("XML document not well formed!"));	
+
 	i = workbook_sheet_count (state.pos.wb);
 	while (i-- > 0)
 		sheet_flag_recompute_spans (workbook_sheet_by_index (state.pos.wb, i));
