From: Xavier Claessens Date: Tue, 24 Sep 2019 14:09:08 +0000 (-0400) Subject: dataurisrc: Do not include trailing `\0` into buffer X-Git-Tag: 1.19.3~1070 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d109dd2752ba2fd02168f714ae05079f1643d562;p=platform%2Fupstream%2Fgstreamer.git dataurisrc: Do not include trailing `\0` into buffer --- diff --git a/plugins/elements/gstdataurisrc.c b/plugins/elements/gstdataurisrc.c index 79521fa..8129cb3 100644 --- a/plugins/elements/gstdataurisrc.c +++ b/plugins/elements/gstdataurisrc.c @@ -388,7 +388,7 @@ gst_data_uri_src_set_uri (GstURIHandler * handler, const gchar * uri, bdata = g_uri_unescape_string (data_start, NULL); if (bdata == NULL) goto invalid_uri_encoded_data; - bsize = strlen (bdata) + 1; + bsize = strlen (bdata); } /* Convert to UTF8 */ if (strcmp ("text/plain", mimetype) == 0 && @@ -399,7 +399,7 @@ gst_data_uri_src_set_uri (GstURIHandler * handler, const gchar * uri, gpointer data; data = - g_convert_with_fallback (bdata, -1, "UTF-8", charset, (char *) "*", + g_convert_with_fallback (bdata, bsize, "UTF-8", charset, (char *) "*", &read, &written, NULL); g_free (bdata); diff --git a/tests/check/elements/dataurisrc.c b/tests/check/elements/dataurisrc.c index 96278ea..6404862 100644 --- a/tests/check/elements/dataurisrc.c +++ b/tests/check/elements/dataurisrc.c @@ -553,11 +553,15 @@ GST_START_TEST (test_dataurisrc_uris) h = gst_harness_new_with_element (src, NULL, "src"); gst_harness_play (h); - buf = gst_harness_pull (h); - fail_unless (buf); - - gst_check_buffer_data (buf, tests[i].contents, tests[i].contents_len); - gst_buffer_unref (buf); + fail_unless (gst_harness_pull_until_eos (h, &buf)); + + if (tests[i].contents_len == 0) { + fail_unless (buf == NULL); + } else { + fail_unless (buf); + gst_check_buffer_data (buf, tests[i].contents, tests[i].contents_len); + gst_buffer_unref (buf); + } gst_harness_teardown (h); gst_object_unref (src);