From 5d3a183f434d4594ddd01d784317b325b9968571 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 22 Dec 2015 19:18:46 +0800 Subject: [PATCH] fix #509, always alloc big object at heap. 2.0.205 --- README.md | 2 ++ trunk/src/core/srs_core.hpp | 2 +- trunk/src/protocol/srs_rtmp_stack.cpp | 16 ++++++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 075ebe014..8f1944529 100755 --- a/README.md +++ b/README.md @@ -337,6 +337,7 @@ Remark: ## History +* v2.0, 2015-12-22, for [#509][bug #509] always alloc big object at heap. 2.0.205 * v2.0, 2015-12-22, for [#418][bug #418] ignore null connect props to make RED5 happy. 2.0.204 * v2.0, 2015-12-22, for [#546][bug #546] thread terminate normally dispose bug. 2.0.203 * v2.0, 2015-12-22, for [#541][bug #541] failed when chunk size too small. 2.0.202 @@ -1213,6 +1214,7 @@ Winlin [bug #541]: https://github.com/ossrs/srs/issues/541 [bug #546]: https://github.com/ossrs/srs/issues/546 [bug #418]: https://github.com/ossrs/srs/issues/418 +[bug #509]: https://github.com/ossrs/srs/issues/509 [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx [exo #828]: https://github.com/google/ExoPlayer/pull/828 diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 4033b2f51..b233541e9 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 204 +#define VERSION_REVISION 205 // server info. #define RTMP_SIG_SRS_KEY "SRS" diff --git a/trunk/src/protocol/srs_rtmp_stack.cpp b/trunk/src/protocol/srs_rtmp_stack.cpp index 0a0f7a5c1..13d25d5fe 100644 --- a/trunk/src/protocol/srs_rtmp_stack.cpp +++ b/trunk/src/protocol/srs_rtmp_stack.cpp @@ -1981,11 +1981,19 @@ int SrsRtmpClient::handshake() srs_assert(hs_bytes); - SrsComplexHandshake complex_hs; - if ((ret = complex_hs.handshake_with_server(hs_bytes, io)) != ERROR_SUCCESS) { + // maybe st has problem when alloc object on stack, always alloc object at heap. + // @see https://github.com/ossrs/srs/issues/509 + SrsComplexHandshake* complex_hs = new SrsComplexHandshake(); + SrsAutoFree(SrsComplexHandshake, complex_hs); + + if ((ret = complex_hs->handshake_with_server(hs_bytes, io)) != ERROR_SUCCESS) { if (ret == ERROR_RTMP_TRY_SIMPLE_HS) { - SrsSimpleHandshake simple_hs; - if ((ret = simple_hs.handshake_with_server(hs_bytes, io)) != ERROR_SUCCESS) { + // always alloc object at heap. + // @see https://github.com/ossrs/srs/issues/509 + SrsSimpleHandshake* simple_hs = new SrsSimpleHandshake(); + SrsAutoFree(SrsSimpleHandshake, simple_hs); + + if ((ret = simple_hs->handshake_with_server(hs_bytes, io)) != ERROR_SUCCESS) { return ret; } }