Skip to content

Fix a minor possible memory leak. #1185

Closed
wants to merge 2 commits into from
View
16 xbmc/addons/Repository.cpp
@@ -92,19 +92,21 @@ CStdString CRepository::FetchChecksum(const CStdString& url)
CSingleLock lock(m_critSection);
CFile file;
file.Open(url);
- CStdString checksum;
try
{
- char* temp = new char[(size_t)file.GetLength()+1];
- file.Read(temp,file.GetLength());
- temp[file.GetLength()] = 0;
- checksum = temp;
- delete[] temp;
+ // we intentionally avoid using file.GetLength() for
+ // Transfer-Encoding: chunked servers.
+ std::stringstream str;
+ char temp[1024];
+ int read;
+ while ((read=file.Read(temp, sizeof(temp))) > 0)
+ str.write(temp, read);
+ return str.str();
}
catch (...)
{
+ return "";
}
- return checksum;
}
CStdString CRepository::GetAddonHash(const AddonPtr& addon)
Something went wrong with that request. Please try again.