[vlc-commits] [Git][videolan/vlc][master] 2 commits: sout: hls: fix double free on error

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Sat Jan 6 13:23:20 UTC 2024



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
82a9de66 by Alaric Senat at 2024-01-06T11:27:16+00:00
sout: hls: fix double free on error

Variant parsing failure already clears the variant map. Calling
`hls_variant_maps_Destroy()` a second time was trigerring a double free.

- - - - -
d395e10d by Alaric Senat at 2024-01-06T11:27:16+00:00
sout: hls: increase playlist count at creation

Instead of increasing it at each ES addition. The previous behavior was
wrongly incrementing the playlist count when multiple ES were muxed in
the same playlist.

- - - - -


1 changed file:

- modules/stream_out/hls/hls.c


Changes:

=====================================
modules/stream_out/hls/hls.c
=====================================
@@ -629,8 +629,13 @@ static void DeletePlaylist(hls_playlist_t *playlist)
 static hls_playlist_t *AddPlaylist(sout_stream_t *stream, struct vlc_list *head)
 {
     hls_playlist_t *variant = CreatePlaylist(stream);
-    if (variant != NULL)
-        vlc_list_append(&variant->node, head);
+    if (variant == NULL)
+        return NULL;
+
+    vlc_list_append(&variant->node, head);
+
+    sout_stream_sys_t *sys = stream->p_sys;
+    ++sys->playlist_created_count;
     return variant;
 }
 
@@ -658,8 +663,6 @@ Add(sout_stream_t *stream, const es_format_t *fmt, const char *es_id)
     if (playlist == NULL)
         return NULL;
 
-    ++sys->playlist_created_count;
-
     sout_input_t *input = sout_MuxAddStream(playlist->mux, fmt);
     if (input == NULL)
         goto error;
@@ -930,7 +933,7 @@ static int Open(vlc_object_t *this)
         msg_Err(stream,
                 "At least one variant mapping needs to be specified with the "
                 "\"" SOUT_CFG_PREFIX "variants\" option");
-        goto error;
+        goto variant_error;
     }
     status = hls_variant_maps_Parse(variants, &sys->variant_stream_maps);
     free(variants);
@@ -940,7 +943,7 @@ static int Open(vlc_object_t *this)
             msg_Err(stream,
                     "Wrong variant mapping syntax. It should look like: "
                     "\"{id1,id2},{id3,id4},...\"");
-        goto error;
+        goto variant_error;
     }
 
     if (var_GetBool(stream, SOUT_CFG_PREFIX "host-http"))
@@ -989,6 +992,7 @@ static int Open(vlc_object_t *this)
     return VLC_SUCCESS;
 error:
     hls_variant_maps_Destroy(&sys->variant_stream_maps);
+variant_error:
     hls_config_Clean(&sys->config);
     free(sys);
     return status;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/97325b0f157af414028b1f2ed0a2551f75c5d8b2...d395e10d4882bc2c9b7947c3ef50cc9f2eff806f

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/97325b0f157af414028b1f2ed0a2551f75c5d8b2...d395e10d4882bc2c9b7947c3ef50cc9f2eff806f
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list