From d798cc1b8d5a83d85d69ec1ce62a02ffd5415236 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Thu, 15 Dec 2011 11:01:01 -0300 Subject: [PATCH] tag: exif: do not include \0 in size passed to g_convert When using g_convert, we should only pass the length of the string content (without the \0) as g_convert will only parse the real contents when changing formats. Including the \0 causes it to add another \0, increasing the string size when not needed. For example, when writting a North geo location ref entry, that should be a string with a single N letter, it would write: "N\0\0", causing the string to have size 3, instead of 2 as expected. In our case, we can pass -1 and let g_convert calculate the strlen as we don't use the length anywhere else. This fixes jifmux's tests on gst-plugins-bad. --- gst-libs/gst/tag/gstexiftag.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gst-libs/gst/tag/gstexiftag.c b/gst-libs/gst/tag/gstexiftag.c index 448943d..4ad3a13 100644 --- a/gst-libs/gst/tag/gstexiftag.c +++ b/gst-libs/gst/tag/gstexiftag.c @@ -779,16 +779,12 @@ write_exif_undefined_tag (GstExifWriter * writer, guint16 tag, static void write_exif_ascii_tag (GstExifWriter * writer, guint16 tag, const gchar * str) { - gint size; guint32 offset = 0; gchar *ascii_str; gsize ascii_size; GError *error = NULL; - size = strlen (str) + 1; - - ascii_str = - g_convert (str, size, "latin1", "utf8", NULL, &ascii_size, &error); + ascii_str = g_convert (str, -1, "latin1", "utf8", NULL, &ascii_size, &error); if (error) { GST_WARNING ("Failed to convert exif tag to ascii: 0x%x - %s. Error: %s", -- 2.7.4