]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
coverity fixes....
authorJaroslav Kysela <perex@perex.cz>
Mon, 10 Nov 2014 13:25:14 +0000 (14:25 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 10 Nov 2014 13:25:14 +0000 (14:25 +0100)
src/access.c
src/api/api_idnode.c
src/epgdb.c
src/input/mpegts/dvb_psi.c
src/muxer/muxer_libav.c
src/plumbing/transcoding.c
src/service.c
src/subscriptions.c

index c7f308cf8a3641207d0cafa80eddc3ae1798606d..c255ec957e647edf3884121b19005e880dddbdf9 100644 (file)
@@ -571,6 +571,10 @@ access_get_hashed(const char *username, const uint8_t digest[20],
       continue; /* IP based access mismatches */
 
     if(ae->ae_username[0] != '*') {
+
+      if (!username)
+        continue;
+
       SHA1_Init(&shactx);
       SHA1_Update(&shactx, (const uint8_t *)ae->ae_password,
                   strlen(ae->ae_password));
index b767d1d6e3a733b5de5457e535b00e0bfdb0a2e9..3765debb15d7b68ac4ffa88218e20c172309e8cc 100644 (file)
@@ -219,7 +219,7 @@ static int
 api_idnode_load
   ( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
 {
-  int err = 0, meta = 0, count = 0;
+  int err = 0, meta, count = 0;
   idnode_t *in;
   htsmsg_t *uuids, *l = NULL, *m;
   htsmsg_t *flist;
@@ -244,7 +244,7 @@ api_idnode_load
   if (!(uuids = htsmsg_field_get_list(f)))
     if (!(uuid = htsmsg_field_get_str(f)))
       return EINVAL;
-  htsmsg_get_s32(args, "meta", &meta);
+  meta = htsmsg_get_s32_or_default(args, "meta", 0);
 
   flist = api_idnode_flist_conf(args, "list");
 
index 1ba29ac604914b96ed02b4710cc3581b5e3d069e..a4a03e934dd7df5dc46386b88d0758b9964e02c5 100644 (file)
@@ -276,11 +276,6 @@ static int _epg_write ( int fd, htsmsg_t *m )
   } else {
     ret = 0;
   }
-  if(ret) {
-    tvhlog(LOG_ERR, "epgdb", "failed to store epg to disk");
-    close(fd);
-    hts_settings_remove("epgdb.v%d", EPG_DB_VERSION);
-  }
   return ret;
 }
 
@@ -313,35 +308,36 @@ void epg_save ( void )
     return;
 
   memset(&stats, 0, sizeof(stats));
-  if ( _epg_write_sect(fd, "config") ) goto fin;
-  if (_epg_write(fd, epg_config_serialize())) goto fin;
-  if ( _epg_write_sect(fd, "brands") ) goto fin;
+  if ( _epg_write_sect(fd, "config") ) goto error;
+  if (_epg_write(fd, epg_config_serialize())) goto error;
+  if ( _epg_write_sect(fd, "brands") ) goto error;
   RB_FOREACH(eo,  &epg_brands, uri_link) {
-    if (_epg_write(fd, epg_brand_serialize((epg_brand_t*)eo))) goto fin;
+    if (_epg_write(fd, epg_brand_serialize((epg_brand_t*)eo))) goto error;
     stats.brands.total++;
   }
-  if ( _epg_write_sect(fd, "seasons") ) goto fin;
+  if ( _epg_write_sect(fd, "seasons") ) goto error;
   RB_FOREACH(eo,  &epg_seasons, uri_link) {
-    if (_epg_write(fd, epg_season_serialize((epg_season_t*)eo))) goto fin;
+    if (_epg_write(fd, epg_season_serialize((epg_season_t*)eo))) goto error;
     stats.seasons.total++;
   }
-  if ( _epg_write_sect(fd, "episodes") ) goto fin;
+  if ( _epg_write_sect(fd, "episodes") ) goto error;
   RB_FOREACH(eo,  &epg_episodes, uri_link) {
-    if (_epg_write(fd, epg_episode_serialize((epg_episode_t*)eo))) goto fin;
+    if (_epg_write(fd, epg_episode_serialize((epg_episode_t*)eo))) goto error;
     stats.episodes.total++;
   }
-  if ( _epg_write_sect(fd, "serieslinks") ) goto fin;
+  if ( _epg_write_sect(fd, "serieslinks") ) goto error;
   RB_FOREACH(eo, &epg_serieslinks, uri_link) {
-    if (_epg_write(fd, epg_serieslink_serialize((epg_serieslink_t*)eo))) goto fin;
+    if (_epg_write(fd, epg_serieslink_serialize((epg_serieslink_t*)eo))) goto error;
     stats.seasons.total++;
   }
-  if ( _epg_write_sect(fd, "broadcasts") ) goto fin;
+  if ( _epg_write_sect(fd, "broadcasts") ) goto error;
   CHANNEL_FOREACH(ch) {
     RB_FOREACH(ebc, &ch->ch_epg_schedule, sched_link) {
-      if (_epg_write(fd, epg_broadcast_serialize(ebc))) goto fin;
+      if (_epg_write(fd, epg_broadcast_serialize(ebc))) goto error;
       stats.broadcasts.total++;
     }
   }
+  close(fd);
 
   /* Stats */
   tvhlog(LOG_INFO, "epgdb", "saved");
@@ -350,6 +346,10 @@ void epg_save ( void )
   tvhlog(LOG_INFO, "epgdb", "  episodes   %d", stats.episodes.total);
   tvhlog(LOG_INFO, "epgdb", "  broadcasts %d", stats.broadcasts.total);
 
-fin:
+  return;
+
+error:
+  tvhlog(LOG_ERR, "epgdb", "failed to store epg to disk");
+  hts_settings_remove("epgdb.v%d", EPG_DB_VERSION);
   close(fd);
 }
index 325acf29fa5d677e30dac8bdb6459e565b19ebc3..baa50b3c20c9545488c1834cc0fd04547326ebcf 100644 (file)
@@ -712,6 +712,8 @@ dvb_bskyb_local_channels
   if (len < 2)
     return;
 
+  assert(bi);
+
   regionid = (ptr[1] != 0xff) ? ptr[1] : 0xffff;
 
 #if 0
@@ -758,7 +760,7 @@ dvb_bskyb_local_channels
         break;
     if (mm && !bs) {
       s = mpegts_service_find(mm, sid, 0, 0, NULL);
-      if (bi && s) {
+      if (s) {
         bs = calloc(1, sizeof(*bs));
         bs->svc = s;
         TAILQ_INSERT_TAIL(&bi->services, bs, link);
index be361d33afe7d47f4644f7c0ecbb55c6546fd965..dc5181740b2e0b57e0d234e88a98f3312865e089 100644 (file)
@@ -497,8 +497,10 @@ lav_muxer_destroy(muxer_t *m)
   if(lm->lm_h264_filter)
     av_bitstream_filter_close(lm->lm_h264_filter);
 
-  for(i=0; i<lm->lm_oc->nb_streams; i++)
-    av_freep(&lm->lm_oc->streams[i]->codec->extradata);
+  if (lm->lm_oc) {
+    for(i=0; i<lm->lm_oc->nb_streams; i++)
+      av_freep(&lm->lm_oc->streams[i]->codec->extradata);
+  }
 
   if(lm->lm_oc && lm->lm_oc->pb) {
     av_freep(&lm->lm_oc->pb->buffer);
index 0566f3bd48adf8abb11fc0fd3c6a51a5f59b87c6..32dc5e71ea71edd7d5981e0774342f0619c827a5 100644 (file)
@@ -919,10 +919,10 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt)
   AVCodec *icodec, *ocodec;
   AVCodecContext *ictx, *octx;
   AVDictionary *opts;
-  AVPacket packet;
+  AVPacket packet, packet2;
   AVPicture deint_pic;
-  uint8_t *buf, *out, *deint;
-  int length, len, got_picture;
+  uint8_t *buf, *deint;
+  int length, len, ret, got_picture, got_output;
   video_stream_t *vs = (video_stream_t*)ts;
 
   ictx = vs->vid_ictx;
@@ -931,7 +931,7 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt)
   icodec = vs->vid_icodec;
   ocodec = vs->vid_ocodec;
 
-  buf = out = deint = NULL;
+  buf = deint = NULL;
   opts = NULL;
 
   if (ictx->codec_id == AV_CODEC_ID_NONE) {
@@ -1136,8 +1136,6 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt)
   else if (ictx->coded_frame && ictx->coded_frame->pts != AV_NOPTS_VALUE)
     vs->vid_enc_frame->pts = vs->vid_dec_frame->pts;
 
-  AVPacket packet2;
-  int ret, got_output;
 
   av_init_packet(&packet2);
   packet2.data = NULL; // packet data will be allocated by the encoder
@@ -1162,9 +1160,6 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt)
   if(buf)
     av_free(buf);
 
-  if(out)
-    av_free(out);
-
   if(deint)
     av_free(deint);
 
index 3ee07fe0e6a49cd20cb0e6aa6780b3d4397e393d..cf1805e15f909cfde3657429ecc0ed6881ac6dc7 100644 (file)
@@ -1502,6 +1502,7 @@ service_instance_add(service_instance_list_t *sil,
   si->si_weight = weight;
   si->si_prio   = prio;
   strncpy(si->si_source, source ?: "<unknown>", sizeof(si->si_source));
+  si->si_source[sizeof(si->si_source)-1] = '\0';
   TAILQ_INSERT_SORTED(sil, si, si_link, si_cmp);
   return si;
 }
index 477ba5d0124a26eaa54a53eeafe4405c2b4e2011..055c5553e599d49dc8b00ffe3cf1b5e668fa7669 100644 (file)
@@ -602,7 +602,7 @@ subscription_create
 
   streaming_target_init(&s->ths_input, cb, s, reject);
 
-  s->ths_prch              = prch->prch_st ? prch : NULL;
+  s->ths_prch              = prch && prch->prch_st ? prch : NULL;
   s->ths_weight            = weight;
   s->ths_title             = strdup(name);
   s->ths_hostname          = hostname ? strdup(hostname) : NULL;