Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2749 from kylhill/master

Fix New Coverity Static Analysis Issues
  • Loading branch information...
commit 66afb93564ba4193de822971ef32255688e339df 2 parents 3011fff + c81266c
Kyle Hill authored
View
3  xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
@@ -1268,9 +1268,6 @@ int CVDPAU::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
}
}
- if (render == NULL)
- return -1;
-
pic->data[1] = pic->data[2] = NULL;
pic->data[0] = (uint8_t*)render;
pic->data[3] = (uint8_t*)(uintptr_t)render->surface;
View
3  xbmc/filesystem/iso9660.cpp
@@ -186,7 +186,7 @@ struct iso_dirtree *iso9660::ReadRecursiveDirFromSector( DWORD sector, const cha
if (!bResult || lpNumberOfBytesRead != wSectorSize)
{
OutputDebugString("unable to read\n");
-
+ free(pCurr_dir_cache);
return NULL;
}
memcpy( &isodir, pCurr_dir_cache, sizeof(isodir) );
@@ -207,6 +207,7 @@ struct iso_dirtree *iso9660::ReadRecursiveDirFromSector( DWORD sector, const cha
if (!bResult || lpNumberOfBytesRead != curr_dirSize)
{
OutputDebugString("unable to read\n");
+ free(pCurr_dir_cache);
return NULL;
}
}
View
2  xbmc/filesystem/udf25.cpp
@@ -607,7 +607,7 @@ int udf25::DVDReadLBUDF( uint32_t lb_number, size_t block_count, unsigned char *
{
int ret;
size_t len = block_count * DVD_VIDEO_LB_LEN;
- int64_t pos = lb_number * DVD_VIDEO_LB_LEN;
+ int64_t pos = lb_number * (int64_t)DVD_VIDEO_LB_LEN;
ret = ReadAt(pos, len, data);
if(ret < 0)
View
3  xbmc/guilib/DirectXGraphics.cpp
@@ -117,6 +117,9 @@ bool IsSwizzledFormat(XB_D3DFORMAT format)
// Currently only works for 32bit and 8bit textures, with power of 2 width and height
void Unswizzle(const void *src, unsigned int depth, unsigned int width, unsigned int height, void *dest)
{
+ if (height <= 0 || width <= 0)
+ return;
+
for (UINT y = 0; y < height; y++)
{
UINT sy = 0;
View
17 xbmc/interfaces/json-rpc/VideoLibrary.cpp
@@ -876,18 +876,21 @@ void CVideoLibrary::UpdateResumePoint(const CVariant &parameterObject, CVideoInf
{
if (!parameterObject["resume"].isNull())
{
- CBookmark bookmark;
- videodatabase.GetResumeBookMark(details.m_strFileNameAndPath, bookmark);
int position = (int)parameterObject["resume"]["position"].asInteger();
- int total = (int)parameterObject["resume"]["total"].asInteger();
if (position == 0)
videodatabase.ClearBookMarksOfFile(details.m_strFileNameAndPath, CBookmark::RESUME);
else
{
- bookmark.timeInSeconds = position;
- if (total > 0)
- bookmark.totalTimeInSeconds = total;
- videodatabase.AddBookMarkToFile(details.m_strFileNameAndPath, bookmark, CBookmark::RESUME);
+ CBookmark bookmark;
+ if (videodatabase.GetResumeBookMark(details.m_strFileNameAndPath, bookmark))
+ {
+ bookmark.timeInSeconds = position;
+
+ int total = (int)parameterObject["resume"]["total"].asInteger();
+ if (total > 0)
+ bookmark.totalTimeInSeconds = total;
+ videodatabase.AddBookMarkToFile(details.m_strFileNameAndPath, bookmark, CBookmark::RESUME);
+ }
}
}
}
View
2  xbmc/music/Album.cpp
@@ -266,7 +266,7 @@ bool CAlbum::Save(TiXmlNode *node, const CStdString &tag, const CStdString& strP
// add a <song> tag
TiXmlElement cast("track");
TiXmlNode *node = album->InsertEndChild(cast);
- for( VECARTISTCREDITS::const_iterator artistCredit = song->artistCredits.begin(); artistCredit != artistCredits.end(); ++artistCredit)
+ for( VECARTISTCREDITS::const_iterator artistCredit = song->artistCredits.begin(); artistCredit != song->artistCredits.end(); ++artistCredit)
{
// add an <albumArtistCredits> tag
TiXmlElement songArtistCreditsElement("songArtistCredits");
View
2  xbmc/music/infoscanner/MusicInfoScanner.cpp
@@ -803,7 +803,7 @@ int CMusicInfoScanner::RetrieveMusicInfo(const CStdString& strDirectory, CFileIt
m_musicDatabase.AddAlbumArtist(cachedArtist->second.idArtist,
cachedAlbum->second.idAlbum,
artistCredit->GetJoinPhrase(),
- artistCredit == album->artistCredits.begin() ? false : true,
+ artistCredit == cachedAlbum->second.artistCredits.begin() ? false : true,
std::distance(cachedAlbum->second.artistCredits.begin(), artistCredit));
}
View
5 xbmc/music/karaoke/karaokevideobackground.cpp
@@ -74,8 +74,9 @@ bool KaraokeVideoBackground::openVideoFile( const CStdString& filename )
// Do we need to modify the output video size? This could happen in two cases:
// 1. Either video dimension is larger than the screen - video needs to be downscaled
// 2. Both video dimensions are smaller than the screen - video needs to be upscaled
- if ( (m_videoWidth > screen_width || m_videoHeight > screen_height )
- || ( m_videoWidth < screen_width && m_videoHeight < screen_height ) )
+ if ( ( m_videoWidth > 0 && m_videoHeight > 0 )
+ && ( ( m_videoWidth > screen_width || m_videoHeight > screen_height )
+ || ( m_videoWidth < screen_width && m_videoHeight < screen_height ) ) )
{
// Calculate the scale coefficients for width/height separately
double scale_width = (double) screen_width / (double) m_videoWidth;
View
12 xbmc/music/windows/GUIWindowMusicBase.cpp
@@ -595,11 +595,13 @@ void CGUIWindowMusicBase::AddItemToPlayList(const CFileItemPtr &pItem, CFileItem
// Genres will still require 2 lookups, and queuing the entire Genre folder
// will require 3 lookups (genre, artist, album)
CMusicDbUrl musicUrl;
- musicUrl.FromString(pItem->GetPath());
- musicUrl.AppendPath("-1/");
- CFileItemPtr item(new CFileItem(musicUrl.ToString(), true));
- item->SetCanQueue(true); // workaround for CanQueue() check above
- AddItemToPlayList(item, queuedItems);
+ if (musicUrl.FromString(pItem->GetPath()))
+ {
+ musicUrl.AppendPath("-1/");
+ CFileItemPtr item(new CFileItem(musicUrl.ToString(), true));
+ item->SetCanQueue(true); // workaround for CanQueue() check above
+ AddItemToPlayList(item, queuedItems);
+ }
return;
}
}
View
1  xbmc/network/NetworkServices.cpp
@@ -740,7 +740,6 @@ bool CNetworkServices::StartUPnP()
ret |= StartUPnPClient();
ret |= StartUPnPServer();
ret |= StartUPnPRenderer();
- return true;
#endif // HAS_UPNP
return ret;
}
View
2  xbmc/network/WebServer.cpp
@@ -786,7 +786,7 @@ bool CWebServer::Start(int port, const string &username, const string &password)
if (!m_running)
{
int v6testSock;
- if ((v6testSock = socket(AF_INET6, SOCK_STREAM, 0)) > 0)
+ if ((v6testSock = socket(AF_INET6, SOCK_STREAM, 0)) >= 0)
{
closesocket(v6testSock);
m_daemon_ip6 = StartMHD(MHD_USE_IPv6, port);
View
6 xbmc/playlists/SmartPlayList.cpp
@@ -111,7 +111,7 @@ static const translateField fields[] = {
{ "died", FieldDied, SortByNone, CSmartPlaylistRule::TEXT_FIELD, false, 21897 }
};
-#define NUM_FIELDS sizeof(fields) / sizeof(translateField)
+static const size_t NUM_FIELDS = sizeof(fields) / sizeof(translateField);
typedef struct
{
@@ -138,7 +138,7 @@ static const operatorField operators[] = {
{ "between", CSmartPlaylistRule::OPERATOR_BETWEEN, 21456 }
};
-#define NUM_OPERATORS sizeof(operators) / sizeof(operatorField)
+static const size_t NUM_OPERATORS = sizeof(operators) / sizeof(operatorField);
typedef struct
{
@@ -163,7 +163,7 @@ static const group groups[] = { { "", FieldUnknown, false, 571 },
{ "tags", FieldTag, false, 20459 },
};
-#define NUM_GROUPS sizeof(groups) / sizeof(group)
+static const size_t NUM_GROUPS = sizeof(groups) / sizeof(group);
CSmartPlaylistRule::CSmartPlaylistRule()
{
View
4 xbmc/profiles/ProfilesManager.cpp
@@ -101,10 +101,10 @@ void CProfilesManager::OnSettingsLoaded()
CDirectory::Create(URIUtils::AddFileToFolder(strDir,"mixed"));
}
-void CProfilesManager::OnSettingsSaved()
+bool CProfilesManager::OnSettingsSaved()
{
// save mastercode
- Save();
+ return Save();
}
void CProfilesManager::OnSettingsCleared()
View
2  xbmc/profiles/ProfilesManager.h
@@ -34,7 +34,7 @@ class CProfilesManager : public ISettingsHandler
virtual bool OnSettingsLoading();
virtual void OnSettingsLoaded();
- virtual void OnSettingsSaved();
+ virtual bool OnSettingsSaved();
virtual void OnSettingsCleared();
bool Load();
View
6 xbmc/settings/Setting.cpp
@@ -75,9 +75,11 @@ bool CSetting::Deserialize(const TiXmlNode *node, bool update /* = false */)
// get the attributes label and help
int tmp = -1;
- if (element->QueryIntAttribute(XML_ATTR_LABEL, &m_label) == TIXML_SUCCESS && tmp > 0)
+ if (element->QueryIntAttribute(XML_ATTR_LABEL, &tmp) == TIXML_SUCCESS && tmp > 0)
m_label = tmp;
- if (element->QueryIntAttribute(XML_ATTR_HELP, &m_help) == TIXML_SUCCESS && tmp > 0)
+
+ tmp = -1;
+ if (element->QueryIntAttribute(XML_ATTR_HELP, &tmp) == TIXML_SUCCESS && tmp > 0)
m_help = tmp;
const char *parentSetting = element->Attribute("parent");
if (parentSetting != NULL)
View
3  xbmc/settings/Settings.cpp
@@ -317,9 +317,8 @@ bool CSettings::Load(const TiXmlElement *root, bool hide /* = false */)
{
for(std::map<std::string, CSetting*>::const_iterator setting = loadedSettings->begin(); setting != loadedSettings->end(); ++setting)
setting->second->SetVisible(false);
-
- delete loadedSettings;
}
+ delete loadedSettings;
return success;
}
View
6 xbmc/windows/GUIWindowLoginScreen.cpp
@@ -104,7 +104,8 @@ bool CGUIWindowLoginScreen::OnMessage(CGUIMessage& message)
if (bOkay)
{
- LoadProfile(iItem);
+ if (iItem >= 0)
+ LoadProfile((unsigned int)iItem);
}
else
{
@@ -248,7 +249,8 @@ bool CGUIWindowLoginScreen::OnPopupMenu(int iItem)
{
int iDelete = m_viewControl.GetSelectedItem();
m_viewControl.Clear();
- CProfilesManager::Get().DeleteProfile(iDelete);
+ if (iDelete >= 0)
+ CProfilesManager::Get().DeleteProfile((size_t)iDelete);
Update();
m_viewControl.SetSelectedItem(0);
}
Please sign in to comment.
Something went wrong with that request. Please try again.