From 49c737f99667978db61ba27f4d8f1954ab6527bb Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 19 Dec 2019 14:39:34 +0800 Subject: [PATCH] Fix #1524, memory leak for amf0 strict array. 3.0.75 --- README.md | 2 ++ trunk/src/core/srs_core.hpp | 2 +- trunk/src/protocol/srs_protocol_amf0.cpp | 12 ++++++------ trunk/src/protocol/srs_protocol_amf0.hpp | 6 +++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 8279a2d05..4465f6011 100755 --- a/README.md +++ b/README.md @@ -145,6 +145,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2019-12-19, Fix [#1524][bug #1524], memory leak for amf0 strict array. 3.0.75 * v3.0, 2019-12-19, Fix random build failed bug for modules. * v3.0, 2019-12-19, Fix [#1520][bug #1520] and [#1223][bug #1223], bug for origin cluster 3+ servers. 3.0.74 * v3.0, 2019-12-18, For [#1042][bug #1042], add test for RAW AVC protocol. @@ -1510,6 +1511,7 @@ Winlin [bug #1339]: https://github.com/ossrs/srs/pull/1339 [bug #1312]: https://github.com/ossrs/srs/pull/1312 [bug #1304]: https://github.com/ossrs/srs/pull/1304 +[bug #1524]: https://github.com/ossrs/srs/issues/1524 [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx [bug #735]: https://github.com/ossrs/srs/issues/735 diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index b1f3fd652..182235ff9 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 74 +#define VERSION_REVISION 75 // The macros generated by configure script. #include diff --git a/trunk/src/protocol/srs_protocol_amf0.cpp b/trunk/src/protocol/srs_protocol_amf0.cpp index a1449e6be..9fc5a3bcc 100644 --- a/trunk/src/protocol/srs_protocol_amf0.cpp +++ b/trunk/src/protocol/srs_protocol_amf0.cpp @@ -1030,12 +1030,7 @@ SrsAmf0StrictArray::SrsAmf0StrictArray() SrsAmf0StrictArray::~SrsAmf0StrictArray() { - std::vector::iterator it; - for (it = properties.begin(); it != properties.end(); ++it) { - SrsAmf0Any* any = *it; - srs_freep(any); - } - properties.clear(); + clear(); } int SrsAmf0StrictArray::total_size() @@ -1147,6 +1142,11 @@ SrsJsonAny* SrsAmf0StrictArray::to_json() void SrsAmf0StrictArray::clear() { + std::vector::iterator it; + for (it = properties.begin(); it != properties.end(); ++it) { + SrsAmf0Any* any = *it; + srs_freep(any); + } properties.clear(); } diff --git a/trunk/src/protocol/srs_protocol_amf0.hpp b/trunk/src/protocol/srs_protocol_amf0.hpp index 389caeeff..84593c557 100644 --- a/trunk/src/protocol/srs_protocol_amf0.hpp +++ b/trunk/src/protocol/srs_protocol_amf0.hpp @@ -356,7 +356,7 @@ public: * convert amf0 to json. */ virtual SrsJsonAny* to_json(); - // properties iteration +// properties iteration public: /** * clear all propergies. @@ -447,7 +447,7 @@ public: * convert amf0 to json. */ virtual SrsJsonAny* to_json(); - // properties iteration +// properties iteration public: /** * clear all propergies. @@ -532,7 +532,7 @@ public: * convert amf0 to json. */ virtual SrsJsonAny* to_json(); - // properties iteration +// properties iteration public: /** * clear all elements.