dataurisrc: Do not include trailing `\0` into buffer
authorXavier Claessens <xavier.claessens@collabora.com>
Tue, 24 Sep 2019 14:09:08 +0000 (10:09 -0400)
committerXavier Claessens <xclaesse@gmail.com>
Mon, 7 Oct 2019 17:47:47 +0000 (17:47 +0000)
plugins/elements/gstdataurisrc.c
tests/check/elements/dataurisrc.c

index 79521fa..8129cb3 100644 (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);
 
index 96278ea..6404862 100644 (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);
-
-    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);