From 764909c6cfad19bfd1fba51dde7dba24d19e0779 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 21 Dec 2020 12:05:56 +0800 Subject: [PATCH] Clear disposing then free resources to avoid reuse addresses --- trunk/src/app/srs_app_conn.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/trunk/src/app/srs_app_conn.cpp b/trunk/src/app/srs_app_conn.cpp index e3ae754d1..e6ca875df 100644 --- a/trunk/src/app/srs_app_conn.cpp +++ b/trunk/src/app/srs_app_conn.cpp @@ -261,9 +261,6 @@ void SrsResourceManager::clear() } do_clear(); - - // Reset it for it points to a local object. - p_disposing_ = NULL; } void SrsResourceManager::do_clear() @@ -286,6 +283,11 @@ void SrsResourceManager::do_clear() dispose(conn); } + // Reset it for it points to a local object. + // @remark We must set the disposing to NULL to avoid reusing address, + // because the context might switch. + p_disposing_ = NULL; + // We should free the resources when finished all disposing callbacks, // which might cause context switch and reuse the freed addresses. for (int i = 0; i < (int)copy.size(); i++) {