wavparse: use g_strndup() for copying text data
authorTim-Philipp Müller <tim@centricular.com>
Sun, 23 May 2021 14:14:11 +0000 (15:14 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Sun, 23 May 2021 14:20:16 +0000 (15:20 +0100)
So we don't rely on NUL terminators inside the data.

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

gst/wavparse/gstwavparse.c

index 3279957..45b9db9 100644 (file)
@@ -837,7 +837,7 @@ gst_wavparse_labl_chunk (GstWavParse * wav, const guint8 * data, guint32 size)
 
   /* parse data */
   labl->cue_point_id = GST_READ_UINT32_LE (data);
-  labl->text = g_memdup (data + 4, size - 4);
+  labl->text = g_strndup ((const gchar *) data + 4, size - 4);
 
   wav->labls = g_list_append (wav->labls, labl);
 
@@ -866,7 +866,7 @@ gst_wavparse_note_chunk (GstWavParse * wav, const guint8 * data, guint32 size)
 
   /* parse data */
   note->cue_point_id = GST_READ_UINT32_LE (data);
-  note->text = g_memdup (data + 4, size - 4);
+  note->text = g_strndup ((const gchar *) data + 4, size - 4);
 
   wav->notes = g_list_append (wav->notes, note);