From d5b28ad783840c22ff82aa1b7746238f7e523f09 Mon Sep 17 00:00:00 2001 From: chenhaibo Date: Fri, 14 May 2021 16:55:26 +0800 Subject: [PATCH] fix bug //@see https://github.com/ossrs/srs/issues/2311 --- trunk/src/app/srs_app_hls.cpp | 9 ++------- trunk/src/app/srs_app_http_stream.cpp | 10 ++++------ trunk/src/app/srs_app_statistic.cpp | 9 +++++++-- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index a607d80a44..3c265a6bc4 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -241,13 +241,8 @@ srs_error_t SrsHlsMuxer::update_config(SrsRequest* r, string entry_prefix, { srs_error_t err = srs_success; - // @see https://github.com/ossrs/srs/issues/2311 - if (req) { - req->update_auth(r); - } - else { - req = r->copy(); - } + srs_freep(req); + req = r->copy(); hls_entry_prefix = entry_prefix; hls_path = path; diff --git a/trunk/src/app/srs_app_http_stream.cpp b/trunk/src/app/srs_app_http_stream.cpp index c90dc2c39d..5e30824e35 100755 --- a/trunk/src/app/srs_app_http_stream.cpp +++ b/trunk/src/app/srs_app_http_stream.cpp @@ -78,9 +78,8 @@ SrsBufferCache::~SrsBufferCache() srs_error_t SrsBufferCache::update(SrsSource* s, SrsRequest* r) { - // @see https://github.com/ossrs/srs/issues/2311 - req->update_auth(r); - + srs_freep(req); + req = r->copy(); source = s; return srs_success; @@ -532,9 +531,8 @@ srs_error_t SrsLiveStream::update(SrsSource* s, SrsRequest* r) { source = s; - // @see https://github.com/ossrs/srs/issues/2311 - req->update_auth(r); - req->as_http(); + srs_freep(req); + req = r->copy()->as_http(); return srs_success; } diff --git a/trunk/src/app/srs_app_statistic.cpp b/trunk/src/app/srs_app_statistic.cpp index 26bb22aad9..416c7ca412 100644 --- a/trunk/src/app/srs_app_statistic.cpp +++ b/trunk/src/app/srs_app_statistic.cpp @@ -214,6 +214,7 @@ SrsStatisticClient::SrsStatisticClient() SrsStatisticClient::~SrsStatisticClient() { + srs_freep(req); } srs_error_t SrsStatisticClient::dumps(SrsJsonObject* obj) @@ -457,11 +458,15 @@ srs_error_t SrsStatistic::on_client(SrsContextId cid, SrsRequest* req, ISrsExpir // got client. client->conn = conn; - client->req = req; client->type = type; stream->nb_clients++; vhost->nb_clients++; - + + // The req might be freed, in such as SrsLiveStream::update, so we must copy it. + // @see https://github.com/ossrs/srs/issues/2311 + srs_freep(client->req); + client->req = req->copy(); + return err; }