winlin

fix memory leak at handshake. 2.0.213

@@ -340,6 +340,8 @@ Remark: @@ -340,6 +340,8 @@ Remark:
340 340
341 ## History 341 ## History
342 342
  343 +* v2.0, 2016-09-05, fix memory leak at handshake. 2.0.213
  344 +* v2.0, 2016-09-04, support valgrind for [patched st](https://github.com/ossrs/state-threads/issues/2).
343 * v2.0, 2016-09-03, support all arm for [patched st](https://github.com/ossrs/state-threads/issues/1). 2.0.212 345 * v2.0, 2016-09-03, support all arm for [patched st](https://github.com/ossrs/state-threads/issues/1). 2.0.212
344 * v2.0, 2016-09-01, workaround [#511][bug #511] the fly stfd in close. 2.0.211 346 * v2.0, 2016-09-01, workaround [#511][bug #511] the fly stfd in close. 2.0.211
345 * v2.0, 2016-08-30, comment the pcr. 347 * v2.0, 2016-08-30, comment the pcr.
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR 2 32 #define VERSION_MAJOR 2
33 #define VERSION_MINOR 0 33 #define VERSION_MINOR 0
34 -#define VERSION_REVISION 212 34 +#define VERSION_REVISION 213
35 35
36 // generated by configure, only macros. 36 // generated by configure, only macros.
37 #include <srs_auto_headers.hpp> 37 #include <srs_auto_headers.hpp>
@@ -152,6 +152,11 @@ namespace _srs_internal @@ -152,6 +152,11 @@ namespace _srs_internal
152 152
153 SrsDH::~SrsDH() 153 SrsDH::~SrsDH()
154 { 154 {
  155 + close();
  156 + }
  157 +
  158 + void SrsDH::close()
  159 + {
155 if (pdh != NULL) { 160 if (pdh != NULL) {
156 if (pdh->p != NULL) { 161 if (pdh->p != NULL) {
157 BN_free(pdh->p); 162 BN_free(pdh->p);
@@ -249,7 +254,9 @@ namespace _srs_internal @@ -249,7 +254,9 @@ namespace _srs_internal
249 { 254 {
250 int ret = ERROR_SUCCESS; 255 int ret = ERROR_SUCCESS;
251 256
252 - int32_t bits_count = 1024; 257 + int32_t bits_count = 1024;
  258 +
  259 + close();
253 260
254 //1. Create the DH 261 //1. Create the DH
255 if ((pdh = DH_new()) == NULL) { 262 if ((pdh = DH_new()) == NULL) {
@@ -59,6 +59,8 @@ namespace _srs_internal @@ -59,6 +59,8 @@ namespace _srs_internal
59 public: 59 public:
60 SrsDH(); 60 SrsDH();
61 virtual ~SrsDH(); 61 virtual ~SrsDH();
  62 + private:
  63 + virtual void close();
62 public: 64 public:
63 /** 65 /**
64 * initialize dh, generate the public and private key. 66 * initialize dh, generate the public and private key.