From e6800008635d992ad0339048729f6b452b3bc10d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 12 May 2021 16:13:25 +0200 Subject: Fix a crash in QGstAppSrc when using pull mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In this case m_stream is a nullptr, make sure we never access it. Change-Id: I095d18fc99a60bc9b5cd9fe1bc33b7879f109c8a Reviewed-by: Lars Knoll Reviewed-by: André de la Rocha --- src/multimedia/platform/gstreamer/common/qgstappsrc.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/multimedia/platform/gstreamer/common/qgstappsrc.cpp b/src/multimedia/platform/gstreamer/common/qgstappsrc.cpp index 2cf33fbce..801db5aff 100644 --- a/src/multimedia/platform/gstreamer/common/qgstappsrc.cpp +++ b/src/multimedia/platform/gstreamer/common/qgstappsrc.cpp @@ -167,10 +167,10 @@ void QGstAppSrc::pushData() if (m_appSrc.isNull() || !m_dataRequestSize) return; - qCDebug(qLcAppSrc) << "pushData" << m_stream << m_stream->atEnd() << m_buffer.size(); + qCDebug(qLcAppSrc) << "pushData" << (m_stream ? m_stream : nullptr) << m_buffer.size(); if ((m_stream && m_stream->atEnd())) { eosOrIdle(); - qCDebug(qLcAppSrc) << "end pushData" << m_stream << m_stream->atEnd() << m_buffer.size(); + qCDebug(qLcAppSrc) << "end pushData" << (m_stream ? m_stream : nullptr) << m_buffer.size(); return; } @@ -183,11 +183,11 @@ void QGstAppSrc::pushData() if (!m_dataRequestSize) m_dataRequestSize = m_maxBytes; size = qMin(size, (qint64)m_dataRequestSize); - qCDebug(qLcAppSrc) << " reading" << size << "bytes" << m_stream->bytesAvailable() << m_dataRequestSize; + qCDebug(qLcAppSrc) << " reading" << size << "bytes" << size << m_dataRequestSize; GstBuffer* buffer = gst_buffer_new_and_alloc(size); - if (m_sequential && m_stream) + if (m_sequential || !m_stream) buffer->offset = bytesReadSoFar; else buffer->offset = m_stream->pos(); @@ -218,7 +218,7 @@ void QGstAppSrc::pushData() if (bytesRead == 0) { gst_buffer_unref(buffer); eosOrIdle(); - qCDebug(qLcAppSrc) << "end pushData" << m_stream << m_stream->atEnd() << m_buffer.size(); + qCDebug(qLcAppSrc) << "end pushData" << (m_stream ? m_stream : nullptr) << m_buffer.size(); return; } m_noMoreData = false; @@ -230,7 +230,7 @@ void QGstAppSrc::pushData() } else if (ret == GST_FLOW_FLUSHING) { qWarning() << "QGstAppSrc: push buffer wrong state"; } - qCDebug(qLcAppSrc) << "end pushData" << m_stream << m_stream->atEnd() << m_buffer.size(); + qCDebug(qLcAppSrc) << "end pushData" << (m_stream ? m_stream : nullptr) << m_buffer.size(); } -- cgit v1.2.3