Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
coverity fixes....
  • Loading branch information
perexg committed Nov 10, 2014
1 parent 1efe779 commit 4e63e0d
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 33 deletions.
4 changes: 4 additions & 0 deletions src/access.c
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions src/api/api_idnode.c
Expand Up @@ -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;
Expand All @@ -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");

Expand Down
36 changes: 18 additions & 18 deletions src/epgdb.c
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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");
Expand All @@ -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);
}
4 changes: 3 additions & 1 deletion src/input/mpegts/dvb_psi.c
Expand Up @@ -712,6 +712,8 @@ dvb_bskyb_local_channels
if (len < 2)
return;

assert(bi);

regionid = (ptr[1] != 0xff) ? ptr[1] : 0xffff;

#if 0
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions src/muxer/muxer_libav.c
Expand Up @@ -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);
Expand Down
13 changes: 4 additions & 9 deletions src/plumbing/transcoding.c
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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);

Expand Down
1 change: 1 addition & 0 deletions src/service.c
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/subscriptions.c
Expand Up @@ -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;
Expand Down

0 comments on commit 4e63e0d

Please sign in to comment.