flvdemux: Handle empty metadata strings
authorEdward Hervey <edward@centricular.com>
Wed, 20 May 2020 08:45:16 +0000 (10:45 +0200)
committerEdward Hervey <bilboed@bilboed.com>
Wed, 20 May 2020 08:48:06 +0000 (10:48 +0200)
g_utf8_validate() errors out on empty string. But empty strings are valid,
so only check if they're not

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/596>

gst/flv/gstflvdemux.c

index 7cfe63f..16356d4 100644 (file)
@@ -202,7 +202,8 @@ FLV_GET_STRING (GstByteReader * reader)
   }
 
   memcpy (string, str, string_size);
-  if (!g_utf8_validate (string, string_size, NULL)) {
+  /* Check utf-8 validity if it's not an empty string */
+  if (string[0] && !g_utf8_validate (string, string_size, NULL)) {
     g_free (string);
     return NULL;
   }