From db6803bd55ae4d0789cc520f8563bd1fc8980eb4 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Mon, 18 Mar 2024 15:07:28 +0100 Subject: [PATCH] adaptivedemux2: Don't use g_str_equal on potentially NULL strings It is only meant to be used as a callback. The fallback macro uses strcmp which doesn't handle NULL strings gracefully. Instead use g_strcmp0 Part-of: --- .../ext/adaptivedemux2/hls/gsthlsdemux-playlist-loader.c | 6 +++--- .../ext/adaptivedemux2/hls/gsthlsdemux-preloader.c | 2 +- .../ext/adaptivedemux2/hls/gsthlsdemux-stream.c | 2 +- .../ext/adaptivedemux2/hls/gsthlsdemux-util.c | 2 +- .../gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c | 4 ++-- subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux-playlist-loader.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux-playlist-loader.c index 02c53dd9f1..e5da0ba371 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux-playlist-loader.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux-playlist-loader.c @@ -309,7 +309,7 @@ gst_hls_demux_playlist_loader_has_current_uri (GstHLSDemuxPlaylistLoader * pl, target_playlist_uri = priv->target_playlist_uri; if (priv->current_playlist == NULL - || !g_str_equal (target_playlist_uri, priv->current_playlist_uri)) + || g_strcmp0 (target_playlist_uri, priv->current_playlist_uri)) return FALSE; return TRUE; @@ -496,7 +496,7 @@ on_download_complete (DownloadRequest * download, DownloadRequestState state, return; } - if (!g_str_equal (priv->target_playlist_uri, priv->loading_playlist_uri)) { + if (g_strcmp0 (priv->target_playlist_uri, priv->loading_playlist_uri)) { /* This callback happened just as the playlist URI was updated. There should be * a pending state update scheduled, but we can just kick off the new download * immediately */ @@ -796,7 +796,7 @@ gst_hls_demux_playlist_loader_update (GstHLSDemuxPlaylistLoader * pl) /* A download is in progress, but if we reach here it's * because the target playlist URI got updated, so check * for cancelling the current download. */ - if (g_str_equal (priv->target_playlist_uri, priv->current_playlist_uri)) + if (!g_strcmp0 (priv->target_playlist_uri, priv->current_playlist_uri)) break; /* A download is in progress. Cancel it and trigger a new one */ diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux-preloader.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux-preloader.c index 7f2020f1ee..88ed46519b 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux-preloader.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux-preloader.c @@ -521,7 +521,7 @@ gst_hls_demux_preloader_provide_request (GstHLSDemuxPreloader * preloader, g_ptr_array_index (preloader->active_preloads, idx); GstM3U8PreloadHint *hint = preload_req->hint; - if (!g_str_equal (hint->uri, target_req->uri)) + if (g_strcmp0 (hint->uri, target_req->uri)) continue; GST_LOG ("Possible matching preload type %d uri: %s, range start:%" diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux-stream.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux-stream.c index 909736e722..27a58ad1f3 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux-stream.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux-stream.c @@ -1396,7 +1396,7 @@ gst_hls_demux_stream_handle_playlist_update (GstHLSDemuxStream * stream, } else if (stream->pending_rendition) { /* Switching rendition configures a new playlist on the loader, * and we should never get a callback for a stale download URI */ - g_assert (g_str_equal (stream->pending_rendition->uri, new_playlist_uri)); + g_assert (!g_strcmp0 (stream->pending_rendition->uri, new_playlist_uri)); gst_hls_rendition_stream_unref (stream->current_rendition); /* Stealing ref */ diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux-util.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux-util.c index ce4f1211d3..7deeb7317c 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux-util.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux-util.c @@ -539,7 +539,7 @@ gst_hlsdemux_handle_content_id3 (GstHLSDemux * demux, if (!gst_tag_list_get_sample (taglist, GST_TAG_PRIVATE_DATA, &priv_data)) goto out; - if (!g_str_equal ("com.apple.streaming.transportStreamTimestamp", + if (g_strcmp0 ("com.apple.streaming.transportStreamTimestamp", gst_structure_get_string (gst_sample_get_info (priv_data), "owner"))) goto out; diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c index fbdd45337f..8ffb95618b 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/gsthlsdemux.c @@ -1085,7 +1085,7 @@ gst_hls_demux_handle_variant_playlist_update (GstHLSDemux * demux, if (demux->pending_variant) { /* The pending variant must always match the one that just got updated: * The loader should only do a callback for the most recently set URI */ - g_assert (g_str_equal (demux->pending_variant->uri, playlist_uri)); + g_assert (!g_strcmp0 (demux->pending_variant->uri, playlist_uri)); gboolean changed = (demux->pending_variant != demux->current_variant); @@ -1162,7 +1162,7 @@ gst_hls_demux_handle_variant_playlist_update_error (GstHLSDemux * demux, /* The variant must always match the one that just got updated: * The loader should only do a callback for the most recently set URI */ - g_assert (g_str_equal (variant->uri, playlist_uri)); + g_assert (!g_strcmp0 (variant->uri, playlist_uri)); /* If we didn't already add this playlist to the failed variants list * do so now. It's possible we get an update error again if we failed diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c index 662aba8c57..c5b986859c 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c @@ -174,7 +174,7 @@ gst_m3u8_preload_hint_equal (GstM3U8PreloadHint * hint1, if (hint1->hint_type != hint2->hint_type) return FALSE; - if (!g_str_equal (hint1->uri, hint2->uri)) + if (g_strcmp0 (hint1->uri, hint2->uri)) return FALSE; if (hint1->offset != hint2->offset) @@ -235,7 +235,7 @@ gst_m3u8_init_file_equal (const GstM3U8InitFile * ifile1, if (ifile1 != NULL && ifile2 == NULL) return FALSE; - if (!g_str_equal (ifile1->uri, ifile2->uri)) + if (g_strcmp0 (ifile1->uri, ifile2->uri)) return FALSE; if (ifile1->offset != ifile2->offset) return FALSE;