Skip to content

Commit

Permalink
DllLibCurl: Cleanup sessions before cleaning up library
Browse files Browse the repository at this point in the history
Fixes memory leaks like this:

Direct leak of 5416 byte(s) in 1 object(s) allocated from:
    #0 0x564b473d8ba1 in calloc (kodi-test+0xa2a8ba1) (BuildId: e17174d164cea5687c750d197e31e6bf0beb86ad)
    #1 0x7f6be8db88fa  (/usr/lib/libcurl.so.4+0x708fa) (BuildId: b5fe52836b4db517485d04822e61ce49b2793833)
    #2 0x564b4fb89895 in XCURL::DllLibCurlGlobal::easy_acquire(char const*, char const*, void**, void**) xbmc/filesystem/DllLibCurl.cpp:208:22
    #3 0x564b4facc484 in XFILE::CCurlFile::Open(CURL const&) xbmc/filesystem/CurlFile.cpp:1086:21
    #4 0x564b4fac72a0 in XFILE::CCurlFile::Service(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&) xbmc/filesystem/CurlFile.cpp:966:7
    #5 0x564b4fac7a69 in XFILE::CCurlFile::Get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&) xbmc/filesystem/CurlFile.cpp:960:10
    #6 0x564b47bbd6f6 in TestWebServer_CanGetCachedRangedFileWithExactIfRange_Test::TestBody() xbmc/network/test/TestWebServer.cpp:900:3
    #7 0x7f6be969665b  (/usr/lib/libgtest.so.1.14.0+0x5365b) (BuildId: d3f0da00423297c687edfdde9cb59f357b95e001)

Indirect leak of 5416 byte(s) in 1 object(s) allocated from:
    #0 0x564b473d8ba1 in calloc (kodi-test+0xa2a8ba1) (BuildId: e17174d164cea5687c750d197e31e6bf0beb86ad)
    #1 0x7f6be8db88fa  (/usr/lib/libcurl.so.4+0x708fa) (BuildId: b5fe52836b4db517485d04822e61ce49b2793833)

Indirect leak of 5376 byte(s) in 2 object(s) allocated from:
    #0 0x564b473d8839 in malloc (kodi-test+0xa2a8839) (BuildId: e17174d164cea5687c750d197e31e6bf0beb86ad)
    #1 0x7f6be8d79a44  (/usr/lib/libcurl.so.4+0x31a44) (BuildId: b5fe52836b4db517485d04822e61ce49b2793833)
[...]
  • Loading branch information
neo1973 committed Dec 10, 2023
1 parent f0b5e78 commit a4acb24
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions xbmc/filesystem/DllLibCurl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ DllLibCurlGlobal::DllLibCurlGlobal()

DllLibCurlGlobal::~DllLibCurlGlobal()
{
for (auto& session : m_sessions)
{
if (session.m_multi && session.m_easy)
multi_remove_handle(session.m_multi, session.m_easy);
if (session.m_easy)
easy_cleanup(session.m_easy);
if (session.m_multi)
multi_cleanup(session.m_multi);
}
// close libcurl
curl_global_cleanup();
}
Expand Down

0 comments on commit a4acb24

Please sign in to comment.