From 60856d5a6fdd8a7b9cb1492197d3aa201a43828d Mon Sep 17 00:00:00 2001 From: Doug Nazar Date: Wed, 12 May 2021 17:43:46 -0400 Subject: xml-formatter: Write xml directly to file Skip allocation of temp buffer (which was undersized). Part-of: --- ges/ges-xml-formatter.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/ges/ges-xml-formatter.c b/ges/ges-xml-formatter.c index 409c5542..0747ccf5 100644 --- a/ges/ges-xml-formatter.c +++ b/ges/ges-xml-formatter.c @@ -953,7 +953,6 @@ _save_subproject_data (GESXmlFormatter * self, SubprojectData * subproj_data, gint line = 1, i; gboolean res = FALSE; gsize start = 0, end = 0; - gchar *subproject_content = NULL; gchar *xml = GES_BASE_XML_FORMATTER (self)->xmlcontent; for (i = 0; xml[i] != '\0'; i++) { @@ -973,17 +972,12 @@ _save_subproject_data (GESXmlFormatter * self, SubprojectData * subproj_data, g_assert (start && end); size = (end - start); - subproject_content = g_malloc (sizeof (gchar) * size); - memcpy (subproject_content, &xml[start], end - start); - subproject_content[end - start] = '\0'; GST_INFO_OBJECT (self, "Saving subproject %s from %d:%d(%" G_GSIZE_FORMAT ") to %d:%d(%" G_GSIZE_FORMAT ")", subproj_data->id, subproj_data->start_line, subproj_data->start_char, start, subproject_end_line, subproject_end_char, end); - res = g_file_set_contents (subproj_data->filename, subproject_content, -1, - error); - g_free (subproject_content); + res = g_file_set_contents (subproj_data->filename, &xml[start], size, error); return res; } -- cgit v1.2.3