From 3e1b54eabae6b03085a1295077473a1b866cdeed Mon Sep 17 00:00:00 2001 From: TangoCash Date: Tue, 7 Nov 2017 13:21:24 +0100 Subject: [PATCH] gstreamer playback: fix possible segfaults Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/b4dfa3929030f9bfa7c54426a39d9e7bc7c1da5d Author: TangoCash Date: 2017-11-07 (Tue, 07 Nov 2017) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libarmbox/playback_gst.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libarmbox/playback_gst.cpp b/libarmbox/playback_gst.cpp index 1f4732e..60b2e5f 100644 --- a/libarmbox/playback_gst.cpp +++ b/libarmbox/playback_gst.cpp @@ -290,7 +290,8 @@ GstBusSyncReply Gst_bus_call(GstBus *bus, GstMessage *msg, gpointer user_data) lt_info_c("%s:%s - /tmp/.id3coverart %d bytes written\n", FILENAME, __FUNCTION__, ret); } } - gst_tag_list_unref(tags); + if (tags) + gst_tag_list_unref(tags); lt_debug_c( "%s:%s - GST_MESSAGE_INFO: update info tags\n", FILENAME, __FUNCTION__); //FIXME: how shall playback handle this event??? break; } @@ -461,7 +462,8 @@ void cPlayback::Close(void) // disconnect sync handler callback GstBus * bus = gst_pipeline_get_bus(GST_PIPELINE (m_gst_playbin)); gst_bus_set_sync_handler(bus, NULL, NULL, NULL); - gst_object_unref(bus); + if (bus) + gst_object_unref(bus); lt_info( "%s:%s - GST bus handler closed\n", FILENAME, __FUNCTION__); } @@ -520,7 +522,8 @@ bool cPlayback::Start(char *filename, int /*vpid*/, int /*vtype*/, int /*apid*/, mAudioStream = 0; init_jump = -1; - gst_tag_list_unref(m_stream_tags); + if (m_stream_tags) + gst_tag_list_unref(m_stream_tags); m_stream_tags = NULL; unlink("/tmp/.id3coverart"); @@ -594,7 +597,8 @@ bool cPlayback::Start(char *filename, int /*vpid*/, int /*vtype*/, int /*apid*/, //gstbus handler GstBus * bus = gst_pipeline_get_bus( GST_PIPELINE(m_gst_playbin) ); gst_bus_set_sync_handler(bus, Gst_bus_call, NULL, NULL); - gst_object_unref(bus); + if (bus) + gst_object_unref(bus); first = true; @@ -899,7 +903,8 @@ void cPlayback::FindAllPids(int *apids, unsigned int *ac3flags, unsigned int *nu g_signal_emit_by_name (m_gst_playbin, "get-audio-pad", i, &pad); GstCaps * caps = gst_pad_get_current_caps(pad); - gst_object_unref(pad); + if (pad) + gst_object_unref(pad); if (!caps) continue; @@ -941,7 +946,8 @@ void cPlayback::FindAllPids(int *apids, unsigned int *ac3flags, unsigned int *nu //return atPCM; ac3flags[i] = 0; - gst_caps_unref(caps); + if (caps) + gst_caps_unref(caps); //(ac3flags[i] > 2) ? ac3flags[i] = 1 : ac3flags[i] = 0;