From 6ec60b0a21e7e55d3cce7dd6da5931fdd318844d Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 5 Sep 2016 09:38:30 +0800 Subject: [PATCH] fix memory leak at handshake. 2.0.213 --- README.md | 2 ++ trunk/src/core/srs_core.hpp | 2 +- trunk/src/protocol/srs_rtmp_handshake.cpp | 9 ++++++++- trunk/src/protocol/srs_rtmp_handshake.hpp | 2 ++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8693a11f2..fe3e7cdae 100755 --- a/README.md +++ b/README.md @@ -340,6 +340,8 @@ Remark: ## History +* v2.0, 2016-09-05, fix memory leak at handshake. 2.0.213 +* v2.0, 2016-09-04, support valgrind for [patched st](https://github.com/ossrs/state-threads/issues/2). * v2.0, 2016-09-03, support all arm for [patched st](https://github.com/ossrs/state-threads/issues/1). 2.0.212 * v2.0, 2016-09-01, workaround [#511][bug #511] the fly stfd in close. 2.0.211 * v2.0, 2016-08-30, comment the pcr. diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index e2da92e2a..c8e496b10 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR 2 #define VERSION_MINOR 0 -#define VERSION_REVISION 212 +#define VERSION_REVISION 213 // generated by configure, only macros. #include diff --git a/trunk/src/protocol/srs_rtmp_handshake.cpp b/trunk/src/protocol/srs_rtmp_handshake.cpp index e712ec0bb..1cfc1a7e5 100644 --- a/trunk/src/protocol/srs_rtmp_handshake.cpp +++ b/trunk/src/protocol/srs_rtmp_handshake.cpp @@ -151,6 +151,11 @@ namespace _srs_internal } SrsDH::~SrsDH() + { + close(); + } + + void SrsDH::close() { if (pdh != NULL) { if (pdh->p != NULL) { @@ -249,7 +254,9 @@ namespace _srs_internal { int ret = ERROR_SUCCESS; - int32_t bits_count = 1024; + int32_t bits_count = 1024; + + close(); //1. Create the DH if ((pdh = DH_new()) == NULL) { diff --git a/trunk/src/protocol/srs_rtmp_handshake.hpp b/trunk/src/protocol/srs_rtmp_handshake.hpp index 982cddf40..f327dbece 100644 --- a/trunk/src/protocol/srs_rtmp_handshake.hpp +++ b/trunk/src/protocol/srs_rtmp_handshake.hpp @@ -59,6 +59,8 @@ namespace _srs_internal public: SrsDH(); virtual ~SrsDH(); + private: + virtual void close(); public: /** * initialize dh, generate the public and private key.