From 5271362c20f12951ed56a3054043b7ba7521e8cf Mon Sep 17 00:00:00 2001 From: pingkai Date: Tue, 18 Feb 2020 12:01:33 +0800 Subject: [PATCH] fix(curl): fix hls play crash Signed-off-by: pingkai --- framework/data_source/curl/CURLConnection.cpp | 7 +++---- framework/data_source/curl/curl_data_source.cpp | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/framework/data_source/curl/CURLConnection.cpp b/framework/data_source/curl/CURLConnection.cpp index 85af27a13..ea638d926 100644 --- a/framework/data_source/curl/CURLConnection.cpp +++ b/framework/data_source/curl/CURLConnection.cpp @@ -687,19 +687,18 @@ int CURLConnection::readBuffer(void *buf, size_t size) /*if (re == CURLE_OK) av_log(mCurlhttpContext.hd,AV_LOG_DEBUG,"download speed is %f\n",downloadSpeed);*/ uint32_t want = std::min(RingBuffergetMaxReadSize(pRbuf), (uint32_t) size); - assert(want > 0); - if (RingBufferReadData(pRbuf, (char *) buf, want) == want) { + if (want > 0 && RingBufferReadData(pRbuf, (char *) buf, want) == want) { mFilePos += want; return want; } /* check if we finished prematurely */ if (!still_running && - (mFileSize <= 0 || mFilePos != mFileSize)) { + (mFileSize > 0 && mFilePos != mFileSize)) { AF_LOGE("%s - Transfer ended before entire file was retrieved pos %lld, size %lld", __FUNCTION__, mFilePos, mFileSize); - return -1; + // return -1; } return 0; diff --git a/framework/data_source/curl/curl_data_source.cpp b/framework/data_source/curl/curl_data_source.cpp index 6dc0f9ee0..71fbfc254 100644 --- a/framework/data_source/curl/curl_data_source.cpp +++ b/framework/data_source/curl/curl_data_source.cpp @@ -233,7 +233,6 @@ void CurlDataSource::closeConnections(bool current) lock_guard lock(mMutex); CURLConnection *deleteConnection = nullptr; vector *pConnections = mConnections; - mPConnection = nullptr; mConnections = nullptr; if (current) {