Skip to content
This repository
Browse code

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 August 02, 2013
3  xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
@@ -1268,9 +1268,6 @@ int CVDPAU::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
1268 1268
     }
1269 1269
   }
1270 1270
 
1271  
-  if (render == NULL)
1272  
-    return -1;
1273  
-
1274 1271
   pic->data[1] = pic->data[2] = NULL;
1275 1272
   pic->data[0] = (uint8_t*)render;
1276 1273
   pic->data[3] = (uint8_t*)(uintptr_t)render->surface;
3  xbmc/filesystem/iso9660.cpp
@@ -186,7 +186,7 @@ struct iso_dirtree *iso9660::ReadRecursiveDirFromSector( DWORD sector, const cha
186 186
   if (!bResult || lpNumberOfBytesRead != wSectorSize)
187 187
   {
188 188
     OutputDebugString("unable to read\n");
189  
-
  189
+    free(pCurr_dir_cache);
190 190
     return NULL;
191 191
   }
192 192
   memcpy( &isodir, pCurr_dir_cache, sizeof(isodir) );
@@ -207,6 +207,7 @@ struct iso_dirtree *iso9660::ReadRecursiveDirFromSector( DWORD sector, const cha
207 207
     if (!bResult || lpNumberOfBytesRead != curr_dirSize)
208 208
     {
209 209
       OutputDebugString("unable to read\n");
  210
+      free(pCurr_dir_cache);
210 211
       return NULL;
211 212
     }
212 213
   }
2  xbmc/filesystem/udf25.cpp
@@ -607,7 +607,7 @@ int udf25::DVDReadLBUDF( uint32_t lb_number, size_t block_count, unsigned char *
607 607
 {
608 608
   int ret;
609 609
   size_t  len = block_count * DVD_VIDEO_LB_LEN;
610  
-  int64_t pos = lb_number   * DVD_VIDEO_LB_LEN;
  610
+  int64_t pos = lb_number   * (int64_t)DVD_VIDEO_LB_LEN;
611 611
 
612 612
   ret = ReadAt(pos, len, data);
613 613
   if(ret < 0)
3  xbmc/guilib/DirectXGraphics.cpp
@@ -117,6 +117,9 @@ bool IsSwizzledFormat(XB_D3DFORMAT format)
117 117
 // Currently only works for 32bit and 8bit textures, with power of 2 width and height
118 118
 void Unswizzle(const void *src, unsigned int depth, unsigned int width, unsigned int height, void *dest)
119 119
 {
  120
+  if (height <= 0 || width <= 0)
  121
+    return;
  122
+
120 123
   for (UINT y = 0; y < height; y++)
121 124
   {
122 125
     UINT sy = 0;
17  xbmc/interfaces/json-rpc/VideoLibrary.cpp
@@ -876,18 +876,21 @@ void CVideoLibrary::UpdateResumePoint(const CVariant &parameterObject, CVideoInf
876 876
 {
877 877
   if (!parameterObject["resume"].isNull())
878 878
   {
879  
-    CBookmark bookmark;
880  
-    videodatabase.GetResumeBookMark(details.m_strFileNameAndPath, bookmark);
881 879
     int position = (int)parameterObject["resume"]["position"].asInteger();
882  
-    int total = (int)parameterObject["resume"]["total"].asInteger();
883 880
     if (position == 0)
884 881
       videodatabase.ClearBookMarksOfFile(details.m_strFileNameAndPath, CBookmark::RESUME);
885 882
     else
886 883
     {
887  
-      bookmark.timeInSeconds = position;
888  
-      if (total > 0)
889  
-        bookmark.totalTimeInSeconds = total;
890  
-      videodatabase.AddBookMarkToFile(details.m_strFileNameAndPath, bookmark, CBookmark::RESUME);
  884
+      CBookmark bookmark;
  885
+      if (videodatabase.GetResumeBookMark(details.m_strFileNameAndPath, bookmark))
  886
+      {
  887
+        bookmark.timeInSeconds = position;
  888
+      
  889
+        int total = (int)parameterObject["resume"]["total"].asInteger();
  890
+        if (total > 0)
  891
+          bookmark.totalTimeInSeconds = total;
  892
+        videodatabase.AddBookMarkToFile(details.m_strFileNameAndPath, bookmark, CBookmark::RESUME);
  893
+      }
891 894
     }
892 895
   }
893 896
 }
2  xbmc/music/Album.cpp
@@ -266,7 +266,7 @@ bool CAlbum::Save(TiXmlNode *node, const CStdString &tag, const CStdString& strP
266 266
     // add a <song> tag
267 267
     TiXmlElement cast("track");
268 268
     TiXmlNode *node = album->InsertEndChild(cast);
269  
-    for( VECARTISTCREDITS::const_iterator artistCredit = song->artistCredits.begin(); artistCredit != artistCredits.end(); ++artistCredit)
  269
+    for( VECARTISTCREDITS::const_iterator artistCredit = song->artistCredits.begin(); artistCredit != song->artistCredits.end(); ++artistCredit)
270 270
     {
271 271
       // add an <albumArtistCredits> tag
272 272
       TiXmlElement songArtistCreditsElement("songArtistCredits");
2  xbmc/music/infoscanner/MusicInfoScanner.cpp
@@ -803,7 +803,7 @@ int CMusicInfoScanner::RetrieveMusicInfo(const CStdString& strDirectory, CFileIt
803 803
       m_musicDatabase.AddAlbumArtist(cachedArtist->second.idArtist,
804 804
                                      cachedAlbum->second.idAlbum,
805 805
                                      artistCredit->GetJoinPhrase(),
806  
-                                     artistCredit == album->artistCredits.begin() ? false : true,
  806
+                                     artistCredit == cachedAlbum->second.artistCredits.begin() ? false : true,
807 807
                                      std::distance(cachedAlbum->second.artistCredits.begin(), artistCredit));
808 808
     }
809 809
 
5  xbmc/music/karaoke/karaokevideobackground.cpp
@@ -74,8 +74,9 @@ bool KaraokeVideoBackground::openVideoFile( const CStdString& filename )
74 74
   // Do we need to modify the output video size? This could happen in two cases:
75 75
   // 1. Either video dimension is larger than the screen - video needs to be downscaled
76 76
   // 2. Both video dimensions are smaller than the screen - video needs to be upscaled
77  
-  if ( (m_videoWidth > screen_width || m_videoHeight > screen_height )
78  
-  || (  m_videoWidth < screen_width && m_videoHeight < screen_height ) )
  77
+  if ( ( m_videoWidth > 0 && m_videoHeight > 0 )
  78
+  && ( ( m_videoWidth > screen_width || m_videoHeight > screen_height )
  79
+  || ( m_videoWidth < screen_width && m_videoHeight < screen_height ) ) )
79 80
   {
80 81
     // Calculate the scale coefficients for width/height separately
81 82
     double scale_width = (double) screen_width / (double) m_videoWidth;
12  xbmc/music/windows/GUIWindowMusicBase.cpp
@@ -595,11 +595,13 @@ void CGUIWindowMusicBase::AddItemToPlayList(const CFileItemPtr &pItem, CFileItem
595 595
       // Genres will still require 2 lookups, and queuing the entire Genre folder
596 596
       // will require 3 lookups (genre, artist, album)
597 597
       CMusicDbUrl musicUrl;
598  
-      musicUrl.FromString(pItem->GetPath());
599  
-      musicUrl.AppendPath("-1/");
600  
-      CFileItemPtr item(new CFileItem(musicUrl.ToString(), true));
601  
-      item->SetCanQueue(true); // workaround for CanQueue() check above
602  
-      AddItemToPlayList(item, queuedItems);
  598
+      if (musicUrl.FromString(pItem->GetPath()))
  599
+      {
  600
+        musicUrl.AppendPath("-1/");
  601
+        CFileItemPtr item(new CFileItem(musicUrl.ToString(), true));
  602
+        item->SetCanQueue(true); // workaround for CanQueue() check above
  603
+        AddItemToPlayList(item, queuedItems);
  604
+      }
603 605
       return;
604 606
     }
605 607
   }
1  xbmc/network/NetworkServices.cpp
@@ -740,7 +740,6 @@ bool CNetworkServices::StartUPnP()
740 740
   ret |= StartUPnPClient();
741 741
   ret |= StartUPnPServer();
742 742
   ret |= StartUPnPRenderer();
743  
-    return true;
744 743
 #endif // HAS_UPNP
745 744
   return ret;
746 745
 }
2  xbmc/network/WebServer.cpp
@@ -786,7 +786,7 @@ bool CWebServer::Start(int port, const string &username, const string &password)
786 786
   if (!m_running)
787 787
   {
788 788
     int v6testSock;
789  
-    if ((v6testSock = socket(AF_INET6, SOCK_STREAM, 0)) > 0)
  789
+    if ((v6testSock = socket(AF_INET6, SOCK_STREAM, 0)) >= 0)
790 790
     {
791 791
       closesocket(v6testSock);
792 792
       m_daemon_ip6 = StartMHD(MHD_USE_IPv6, port);
6  xbmc/playlists/SmartPlayList.cpp
@@ -111,7 +111,7 @@ static const translateField fields[] = {
111 111
   { "died",              FieldDied,                    SortByNone,                     CSmartPlaylistRule::TEXT_FIELD,     false, 21897 }
112 112
 };
113 113
 
114  
-#define NUM_FIELDS sizeof(fields) / sizeof(translateField)
  114
+static const size_t NUM_FIELDS = sizeof(fields) / sizeof(translateField);
115 115
 
116 116
 typedef struct
117 117
 {
@@ -138,7 +138,7 @@ static const operatorField operators[] = {
138 138
   { "between",         CSmartPlaylistRule::OPERATOR_BETWEEN,           21456 }
139 139
 };
140 140
 
141  
-#define NUM_OPERATORS sizeof(operators) / sizeof(operatorField)
  141
+static const size_t NUM_OPERATORS = sizeof(operators) / sizeof(operatorField);
142 142
 
143 143
 typedef struct
144 144
 {
@@ -163,7 +163,7 @@ static const group groups[] = { { "",           FieldUnknown,   false,    571 },
163 163
                                 { "tags",       FieldTag,       false,  20459 },
164 164
                               };
165 165
 
166  
-#define NUM_GROUPS sizeof(groups) / sizeof(group)
  166
+static const size_t NUM_GROUPS = sizeof(groups) / sizeof(group);
167 167
 
168 168
 CSmartPlaylistRule::CSmartPlaylistRule()
169 169
 {
4  xbmc/profiles/ProfilesManager.cpp
@@ -101,10 +101,10 @@ void CProfilesManager::OnSettingsLoaded()
101 101
   CDirectory::Create(URIUtils::AddFileToFolder(strDir,"mixed"));
102 102
 }
103 103
 
104  
-void CProfilesManager::OnSettingsSaved()
  104
+bool CProfilesManager::OnSettingsSaved()
105 105
 {
106 106
   // save mastercode
107  
-  Save();
  107
+  return Save();
108 108
 }
109 109
 
110 110
 void CProfilesManager::OnSettingsCleared()
2  xbmc/profiles/ProfilesManager.h
@@ -34,7 +34,7 @@ class CProfilesManager : public ISettingsHandler
34 34
 
35 35
   virtual bool OnSettingsLoading();
36 36
   virtual void OnSettingsLoaded();
37  
-  virtual void OnSettingsSaved();
  37
+  virtual bool OnSettingsSaved();
38 38
   virtual void OnSettingsCleared();
39 39
 
40 40
   bool Load();
6  xbmc/settings/Setting.cpp
@@ -75,9 +75,11 @@ bool CSetting::Deserialize(const TiXmlNode *node, bool update /* = false */)
75 75
 
76 76
   // get the attributes label and help
77 77
   int tmp = -1;
78  
-  if (element->QueryIntAttribute(XML_ATTR_LABEL, &m_label) == TIXML_SUCCESS && tmp > 0)
  78
+  if (element->QueryIntAttribute(XML_ATTR_LABEL, &tmp) == TIXML_SUCCESS && tmp > 0)
79 79
     m_label = tmp;
80  
-  if (element->QueryIntAttribute(XML_ATTR_HELP, &m_help) == TIXML_SUCCESS && tmp > 0)
  80
+  
  81
+  tmp = -1;
  82
+  if (element->QueryIntAttribute(XML_ATTR_HELP, &tmp) == TIXML_SUCCESS && tmp > 0)
81 83
     m_help = tmp;
82 84
   const char *parentSetting = element->Attribute("parent");
83 85
   if (parentSetting != NULL)
3  xbmc/settings/Settings.cpp
@@ -317,9 +317,8 @@ bool CSettings::Load(const TiXmlElement *root, bool hide /* = false */)
317 317
   {
318 318
     for(std::map<std::string, CSetting*>::const_iterator setting = loadedSettings->begin(); setting != loadedSettings->end(); ++setting)
319 319
       setting->second->SetVisible(false);
320  
-
321  
-    delete loadedSettings;
322 320
   }
  321
+  delete loadedSettings;
323 322
 
324 323
   return success;
325 324
 }
6  xbmc/windows/GUIWindowLoginScreen.cpp
@@ -104,7 +104,8 @@ bool CGUIWindowLoginScreen::OnMessage(CGUIMessage& message)
104 104
 
105 105
           if (bOkay)
106 106
           {
107  
-            LoadProfile(iItem);
  107
+            if (iItem >= 0)
  108
+              LoadProfile((unsigned int)iItem);
108 109
           }
109 110
           else
110 111
           {
@@ -248,7 +249,8 @@ bool CGUIWindowLoginScreen::OnPopupMenu(int iItem)
248 249
   {
249 250
     int iDelete = m_viewControl.GetSelectedItem();
250 251
     m_viewControl.Clear();
251  
-    CProfilesManager::Get().DeleteProfile(iDelete);
  252
+    if (iDelete >= 0)
  253
+      CProfilesManager::Get().DeleteProfile((size_t)iDelete);
252 254
     Update();
253 255
     m_viewControl.SetSelectedItem(0);
254 256
   }

0 notes on commit 66afb93

Please sign in to comment.
Something went wrong with that request. Please try again.