Repository: xbmc/xbmc
File: xbmc/filesystem/CurlFile.cpp (C++)

Code before:
  {
    if( !h.GetValue("icy-notice1").empty()
    || !h.GetValue("icy-name").empty()
    || !h.GetValue("icy-br").empty() )
      h.AddParam("Content-Type", "audio/mpeg");
  }

  /* hack for google video */
  if (StringUtils::EqualsNoCase(h.GetMimeType(),"text/html")
  &&  !h.GetValue("Content-Disposition").empty() )
  {
    std::string strValue = h.GetValue("Content-Disposition");
    if (strValue.find("filename=") != std::string::npos &&
        strValue.find(".flv") != std::string::npos)
      h.AddParam("Content-Type", "video/flv");
  }
}

void CCurlFile::ParseAndCorrectUrl(CURL &url2)
{
  std::string strProtocol = url2.GetTranslatedProtocol();
  url2.SetProtocol(strProtocol);

  // lookup host in DNS cache
  std::string resolvedHost;
  auto dnsCache = CServiceBroker::GetDNSNameCache();
  if (dnsCache && dnsCache->GetCached(url2.GetHostName(), resolvedHost))
  {
    struct curl_slist* tempCache;
    int entryPort = url2.GetPort();

    if (entryPort == 0)
    {
      if (strProtocol == "http")
        entryPort = 80;
      else if (strProtocol == "https")
        entryPort = 443;
      else if (strProtocol == "ftp")
        entryPort = 21;
      else if (strProtocol == "ftps")
        entryPort = 990;
    }

    std::string entryString =
        url2.GetHostName() + ":" + std::to_string(entryPort) + ":" + resolvedHost;
    tempCache = g_curlInterface.slist_append(m_dnsCacheList, entryString.c_str());

    if (tempCache)
      m_dnsCacheList = tempCache;
  }


Review comment (bug):
Replace `auto`by actual type `std::shared_ptr<CDNSNameCache>`?
Maybe this even could be `const std::shared_ptr<CDNSNameCache>`?
Why the new nullptr check? Did you experience any crashes? Isn't the cache supposed to be always available?

Code after:
  {
    if( !h.GetValue("icy-notice1").empty()
    || !h.GetValue("icy-name").empty()
    || !h.GetValue("icy-br").empty() )
      h.AddParam("Content-Type", "audio/mpeg");
  }

  /* hack for google video */
  if (StringUtils::EqualsNoCase(h.GetMimeType(),"text/html")
  &&  !h.GetValue("Content-Disposition").empty() )
  {
    std::string strValue = h.GetValue("Content-Disposition");
    if (strValue.find("filename=") != std::string::npos &&
        strValue.find(".flv") != std::string::npos)
      h.AddParam("Content-Type", "video/flv");
  }
}

void CCurlFile::ParseAndCorrectUrl(CURL &url2)
{
  std::string strProtocol = url2.GetTranslatedProtocol();
  url2.SetProtocol(strProtocol);

  // lookup host in DNS cache
  std::string resolvedHost;
  const std::shared_ptr<CDNSNameCache> dnsCache = CServiceBroker::GetDNSNameCache();
  if (dnsCache && dnsCache->GetCached(url2.GetHostName(), resolvedHost))
  {
    struct curl_slist* tempCache;
    int entryPort = url2.GetPort();

    if (entryPort == 0)
    {
      if (strProtocol == "http")
        entryPort = 80;
      else if (strProtocol == "https")
        entryPort = 443;
      else if (strProtocol == "ftp")
        entryPort = 21;
      else if (strProtocol == "ftps")
        entryPort = 990;
    }

    std::string entryString =
        url2.GetHostName() + ":" + std::to_string(entryPort) + ":" + resolvedHost;
    tempCache = g_curlInterface.slist_append(m_dnsCacheList, entryString.c_str());

    if (tempCache)
      m_dnsCacheList = tempCache;
  }