webrtc/nice: fix small leak of split strings
authorMathieu Duponchelle <mathieu@centricular.com>
Fri, 14 Oct 2022 16:51:43 +0000 (18:51 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 14 Oct 2022 20:15:00 +0000 (20:15 +0000)
g_strfreev previously stopped at our manual NULL-termination. Fix by
restoring the pointer after joining.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3188>

subprojects/gst-plugins-bad/gst-libs/gst/webrtc/nice/nice.c

index 379e133..ec165a2 100644 (file)
@@ -730,6 +730,7 @@ get_candidate_address (const gchar * candidate, gchar ** prefix,
     gchar ** address, gchar ** postfix)
 {
   char **tokens = NULL;
+  char *tmp_address = NULL;
 
   if (!g_str_has_prefix (candidate, "a=candidate:")) {
     GST_ERROR ("candidate \"%s\" does not start with \"a=candidate:\"",
@@ -748,14 +749,18 @@ get_candidate_address (const gchar * candidate, gchar ** prefix,
     goto failure;
   }
 
+  tmp_address = tokens[4];
   if (address)
-    *address = g_strdup (tokens[4]);
+    *address = g_strdup (tmp_address);
   tokens[4] = NULL;
+
   if (prefix)
     *prefix = g_strjoinv (" ", tokens);
   if (postfix)
     *postfix = g_strdup (tokens[5]);
 
+  tokens[4] = tmp_address;
+
   g_strfreev (tokens);
   return TRUE;