Skip to content
This repository

Fix curl slist related double append and memory leak #2279

Merged
merged 2 commits into from over 1 year ago

3 participants

ulion Joakim Plate arnova
ulion
Collaborator

there's 2 commit in this pr, related to the curl slist code.
1. for the double append to m_curlAliasList problem.
2. for the slist not released for Exists/Stat call of CurlFile.

xbmc/filesystem/CurlFile.cpp
... ... @@ -467,7 +466,10 @@ void CCurlFile::SetCommonOptions(CReadState* state)
467 466 g_curlInterface.easy_setopt(h, CURLOPT_FAILONERROR, 1);
468 467
469 468 // enable support for icecast / shoutcast streams
470   - m_curlAliasList = g_curlInterface.slist_append(m_curlAliasList, "ICY 200 OK");
  469 + if ( NULL == m_curlAliasList )
  470 + // m_curlAliasList is used only by this one place, but SetCommonOptions can
  471 + // be called mutilple times, only append to list if it's empty.
1
arnova Collaborator
arnova added a note

mutilple -> multiple ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
ulion
Collaborator

If no objection, this will be merged after 2 days.

Joakim Plate
Collaborator
ulion
Collaborator

It's not unrelated, it just need to free the curl slists anyway, Exists/Stat only use the slist and not call Open, but slist need be free, so the Close() can be safely used here. Yes, I checked the Close() code, it's ok if no Open() get called before, mainly the m_state->Disconnect() is need to look into, and it's also clean.

ulion
Collaborator

@elupus I'm going to merge, ok with this?

Joakim Plate
Collaborator
ulion ulion merged commit ba38112 into from
ulion ulion closed this
ulion ulion deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 5 additions and 3 deletions. Show diff stats Hide diff stats

  1. +5 3 xbmc/filesystem/CurlFile.cpp
8 xbmc/filesystem/CurlFile.cpp
@@ -340,8 +340,7 @@ void CCurlFile::CReadState::Disconnect()
340 340
341 341 CCurlFile::~CCurlFile()
342 342 {
343   - if (m_opened)
344   - Close();
  343 + Close();
345 344 delete m_state;
346 345 g_curlInterface.Unload();
347 346 }
@@ -467,7 +466,10 @@ void CCurlFile::SetCommonOptions(CReadState* state)
467 466 g_curlInterface.easy_setopt(h, CURLOPT_FAILONERROR, 1);
468 467
469 468 // enable support for icecast / shoutcast streams
470   - m_curlAliasList = g_curlInterface.slist_append(m_curlAliasList, "ICY 200 OK");
  469 + if ( NULL == m_curlAliasList )
  470 + // m_curlAliasList is used only by this one place, but SetCommonOptions can
  471 + // be called multiple times, only append to list if it's empty.
  472 + m_curlAliasList = g_curlInterface.slist_append(m_curlAliasList, "ICY 200 OK");
471 473 g_curlInterface.easy_setopt(h, CURLOPT_HTTP200ALIASES, m_curlAliasList);
472 474
473 475 // never verify peer, we don't have any certificates to do this

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.