]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
More coverity fixes
authorFlole998 <flole@flole.de>
Thu, 18 Feb 2021 15:48:31 +0000 (16:48 +0100)
committerFlole998 <Flole998@users.noreply.github.com>
Thu, 18 Feb 2021 15:49:30 +0000 (16:49 +0100)
src/api/api_epg.c
src/config.c
src/dvr/dvr_db.c
src/epggrab/module/opentv.c
src/htsp_server.c
src/imagecache.c
src/input/mpegts/dvb_psi_hbbtv.c
src/misc/m3u.c
src/tvh_thread.c

index 27bbc1d0c0a1ea83165e88ad1b028fcec1ca6c7d..f7b38c301dab5a305ceff7b375b581b982c95163 100644 (file)
@@ -598,13 +598,15 @@ api_epg_alternative
   ( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
 {
   uint32_t id, entries = 0;
-  htsmsg_t *l = htsmsg_create_list();
+  htsmsg_t *l;
   epg_broadcast_t *e;
   char *lang;
 
   if (htsmsg_get_u32(args, "eventId", &id))
     return EINVAL;
 
+  l = htsmsg_create_list();
+
   /* Main Job */
   lang = access_get_lang(perm, htsmsg_get_str(args, "lang"));
   tvh_mutex_lock(&global_lock);
@@ -663,6 +665,7 @@ api_epg_related
       /* Have to unlock here since grid will re-lock */
       tvh_mutex_unlock(&global_lock);
       free(lang);
+      htsmsg_destroy(l);
       /* And let the grid do the query for us */
       return api_epg_grid(perm, opaque, op, args, resp);
     }
@@ -685,7 +688,7 @@ api_epg_load
   ( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
 {
   uint32_t id = 0, entries = 0;
-  htsmsg_t *l = htsmsg_create_list(), *ids = NULL, *m;
+  htsmsg_t *l, *ids = NULL, *m;
   htsmsg_field_t *f;
   epg_broadcast_t *e;
   const char *blank = NULL;
@@ -697,6 +700,8 @@ api_epg_load
     if (htsmsg_field_get_u32(f, &id))
       return EINVAL;
 
+  l = htsmsg_create_list();
+
   /* Main Job */
   tvh_mutex_lock(&global_lock);
   lang = access_get_lang(perm, htsmsg_get_str(args, "lang"));
index 6c7bf6511e170b069ed3d5d49a8360fbe39da408..6b77000fb45c64448a9554814f81e6dd2f6ba28a 100644 (file)
@@ -184,7 +184,10 @@ config_migrate_v1_dvb_network
 
   /* Load the adapter config */
   if (!(tun = hts_settings_load("dvbadapters/%s", name))) return;
-  if (!(str = htsmsg_get_str(tun, "type"))) return;
+  if (!(str = htsmsg_get_str(tun, "type"))) {
+    htsmsg_destroy(tun);
+    return;
+  }
   type = str;
 
   /* Create network entry */
@@ -272,6 +275,7 @@ config_migrate_v1_dvb_network
   htsmsg_add_str(net, "networkname", name);
   hts_settings_save(net, "input/linuxdvb/networks/%s/config",
                     uuid_get_hex(&netu, ubuf));
+  htsmsg_destroy(tun);
   htsmsg_destroy(net);
 }
 
@@ -350,7 +354,7 @@ static void
 config_migrate_v1 ( void )
 {
   tvh_uuid_t netu, muxu, svcu, chnu;
-  htsmsg_t *c, *m, *e, *l;
+  htsmsg_t *c, *e, *l, *m = NULL;
   htsmsg_field_t *f;
   uint32_t u32;
   const char *str;
@@ -396,6 +400,7 @@ config_migrate_v1 ( void )
 
     /* Create a network */
     uuid_set(&netu, NULL);
+    if(m != NULL) htsmsg_destroy(m);
     m = htsmsg_create_map();
     htsmsg_add_str(m, "networkname",    "IPTV Network");
     htsmsg_add_u32(m, "skipinitscan",   1);
@@ -886,6 +891,7 @@ config_migrate_v9 ( void )
       hts_settings_remove("autorec/%s", htsmsg_field_name(f));
       hts_settings_save(e, "dvr/autorec/%s", htsmsg_field_name(f));
     }
+    htsmsg_destroy(c);
   }
 }
 
index 7205b170df244565149b4c30144f1224fd6e34ae..0ae44395bb5a784ebba7cff2f8728f01ad28fec1 100644 (file)
@@ -2619,6 +2619,7 @@ dosave:
     if (dvr_autorec_entry_can_be_purged(de)) {
         dvr_entry_assign_broadcast(de, NULL);
         dvr_entry_destroy(de, 1);
+        de = NULL;
     }
   }
 
@@ -3989,7 +3990,7 @@ dvr_entry_class_genre_get(void *o)
 {
   const dvr_entry_t *de = (dvr_entry_t *)o;
   htsmsg_t *l = htsmsg_create_list();
-  if (de->de_bcast && de->de_bcast) {
+  if (de && de->de_bcast) {
     epg_genre_t *eg;
     LIST_FOREACH(eg, &de->de_bcast->genre, link) {
       htsmsg_add_u32(l, NULL, eg->code);
index 814ab89f4358cd02bdeb857a33ebef5a2864c1fb..fa73927c6ea09051a750a6230da0002eba622575 100644 (file)
@@ -233,9 +233,10 @@ static void opentv_remove_entry(opentv_status_t *sta, opentv_entry_t *entry)
 /* Add event entry */
 static void opentv_add_entry(opentv_status_t *sta, opentv_event_t *ev)
 {
+  if (sta == NULL) return;
+
   opentv_entry_t *entry, *nentry = calloc(1, sizeof(*nentry));
 
-  if (sta == NULL) return;
   nentry->event = *ev;
   entry = RB_INSERT_SORTED(&sta->os_entries, nentry, link, _entry_cmp);
   if (entry) {
index 4ec0a90ff4874967661ff738a48c0bc466948c9f..5cccb499fb2afb055e22154d9673ee158a571d97 100644 (file)
@@ -696,6 +696,9 @@ htsp_serierec_convert(htsp_connection_t *htsp, htsmsg_t *in, channel_t *ch, int
   if (ch || !add) {
     htsmsg_add_str(conf, "channel", ch ? idnode_uuid_as_str(&ch->ch_id, ubuf) : "");
   }
+
+  htsmsg_destroy(days);
+
   return conf;
 }
 
index d4dd3c8f77952b7c7006d3594e91fb2fbf14bc92..7a93d6791fbc7437bbabdfb541f0aa68e75e3a2a 100644 (file)
@@ -299,6 +299,8 @@ imagecache_image_fetch ( imagecache_image_t *img )
   tvhpoll_t *efd = NULL;
   http_client_t *hc = NULL;
 
+  urlinit(&url);
+
   lock_assert(&imagecache_lock);
 
   if (img->url == NULL || img->url[0] == '\0')
@@ -315,8 +317,6 @@ imagecache_image_fetch ( imagecache_image_t *img )
   /* Fetch (release lock, incase of delays) */
   tvh_mutex_unlock(&imagecache_lock);
 
-  urlinit(&url);
-
   /* Build command */
   tvhdebug(LS_IMAGECACHE, "fetch %s", img->url);
   memset(&url, 0, sizeof(url));
index 3eba6e25343251043068ab98798d4d4b56785fb1..fd64a69c70e8061cb2ccd996916fcf87060cfeda 100644 (file)
@@ -95,6 +95,7 @@ dvb_psi_parse_hbbtv
         }
         break;
       case DVB_DESC_APP_NAME:
+        if(titles != NULL) htsmsg_destroy(titles);
         titles = htsmsg_create_list();
         while (dlen > 4) {
           r = dvb_get_string_with_len(title, sizeof(title), dptr + 3, dlen - 3, "UTF-8", NULL);
index 6e93f51c366110ae527a9e5813ecb19c441dc3fa..cc5dc48e6ac27be63a8f77b55bb4b13e865507a0 100644 (file)
@@ -297,6 +297,8 @@ multi:
   htsmsg_destroy(key);
   if (l == NULL)
     l = htsmsg_create_list();
+  if (item != NULL)
+    htsmsg_destroy(item);
   htsmsg_add_msg(m, "items", l);
   return m;
 }
index 70cfcb69dabd7dbe674dbecba47f37e05166e5cb..e0f5d02ebb45a69c34688787235ea4ee5b80f2ad 100644 (file)
@@ -462,6 +462,7 @@ static void tvh_thread_deadlock_write(htsbuf_queue_t *q)
       break;
     tvhdbg(LS_THREAD, "%s", s2);
   }
+  if (fd != fd_stderr) close(fd);
 }
 #endif