dataurisrc: Do not include trailing \0 into buffer

This commit is contained in:
Xavier Claessens 2019-09-24 10:09:08 -04:00 committed by Xavier Claessens
parent fe9e49da87
commit d109dd2752
2 changed files with 10 additions and 6 deletions

View file

@ -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);

View file

@ -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);
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);