From a570169a2727693d2ce34bdf2436802dd8c671bf Mon Sep 17 00:00:00 2001 From: ChenGH Date: Sun, 14 May 2023 12:04:58 +0800 Subject: [PATCH] asan: Fix memory leak in asan by releasing global IPs when run_directly_or_daemon fails. v5.0.154, v6.0.44 (#3541) - Resolved a memory leak issue in asan when run_directly_or_daemon fails - Previously, global IP lists were not freed, causing asan to report memory leaks - Updated the code to always free global IP lists, regardless of whether run_directly_or_daemon fails or succeeds --------- Co-authored-by: chundonglinlin --- trunk/doc/CHANGELOG.md | 1 + trunk/src/core/srs_core_version5.hpp | 2 +- trunk/src/main/srs_main_server.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 616254ba7d..4ff6781641 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -8,6 +8,7 @@ The changelog for SRS. ## SRS 5.0 Changelog +* v5.0, 2023-05-13, Merge [#3541](https://github.com/ossrs/srs/pull/3541): asan: Fix memory leak in asan by releasing global IPs when run_directly_or_daemon fails. v5.0.154 (#3541) * v5.0, 2023-05-12, Merge [#3539](https://github.com/ossrs/srs/pull/3539): WHIP: Improve HTTP DELETE for notifying server unpublish event. v5.0.153 (#3539) * v5.0, 2023-03-27, Merge [#3450](https://github.com/ossrs/srs/pull/3450): WebRTC: Error message carries the SDP when failed. v5.0.151 (#3450) * v5.0, 2023-03-25, Merge [#3477](https://github.com/ossrs/srs/pull/3477): Remove unneccessary NULL check in srs_freep. v5.0.150 (#3477) diff --git a/trunk/src/core/srs_core_version5.hpp b/trunk/src/core/srs_core_version5.hpp index 5fff03db0b..59e6836af2 100644 --- a/trunk/src/core/srs_core_version5.hpp +++ b/trunk/src/core/srs_core_version5.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 5 #define VERSION_MINOR 0 -#define VERSION_REVISION 153 +#define VERSION_REVISION 154 #endif diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index 6717640514..519b7ef384 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -241,12 +241,12 @@ srs_error_t do_main(int argc, char** argv, char** envp) #ifdef SRS_SANITIZER_LOG __asan_set_error_report_callback(asan_report_callback); #endif - - if ((err = run_directly_or_daemon()) != srs_success) { - return srs_error_wrap(err, "run"); - } + err = run_directly_or_daemon(); srs_free_global_system_ips(); + if (err != srs_success) { + return srs_error_wrap(err, "run"); + } return err; }