]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
prop: prop_sbuf / prop_ptr cleanups
authorJaroslav Kysela <perex@perex.cz>
Fri, 29 Sep 2017 07:31:52 +0000 (09:31 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 29 Sep 2017 07:31:58 +0000 (09:31 +0200)
The prop get string callbacks should use static buffers. This
patch is trying to fix the problematic parts (mostly in dvr_db.c)
and also introduces prop_ptr to not allocate static pointer
in each string get callback.

The problems in dvb_db.c were serious, so tvh could crash or
invalid data are written to the config files.

Issue: #4636

16 files changed:
src/access.c
src/bouquet.c
src/channels.c
src/descrambler/caclient.c
src/descrambler/cccam.c
src/descrambler/constcw.c
src/descrambler/cwc.c
src/dvr/dvr_autorec.c
src/dvr/dvr_db.c
src/dvr/dvr_timerec.c
src/input/mpegts/linuxdvb/linuxdvb_frontend.c
src/input/mpegts/linuxdvb/linuxdvb_satconf.c
src/input/mpegts/mpegts_mux_dvb.c
src/input/mpegts/mpegts_network_dvb.c
src/prop.c
src/prop.h

index cedd27a8e0bfbb8cb6a18780b66efc85861e1e68..06b791ca9fa8ae965e4f99d982a4a1e8721ab398 100644 (file)
@@ -1242,9 +1242,8 @@ access_entry_class_prefix_set(void *o, const void *v)
 static const void *
 access_entry_class_prefix_get(void *o)
 {
-  static const char *ret;
-  ret = access_get_prefix(&((access_entry_t *)o)->ae_ipmasks);
-  return &ret;
+  prop_ptr = access_get_prefix(&((access_entry_t *)o)->ae_ipmasks);
+  return &prop_ptr;
 }
 
 static int
@@ -2167,9 +2166,8 @@ ipblock_entry_class_prefix_set(void *o, const void *v)
 static const void *
 ipblock_entry_class_prefix_get(void *o)
 {
-  static const char *ret;
-  ret = access_get_prefix(&((ipblock_entry_t *)o)->ib_ipmasks);
-  return &ret;
+  prop_ptr = access_get_prefix(&((ipblock_entry_t *)o)->ib_ipmasks);
+  return &prop_ptr;
 }
 
 CLASS_DOC(ipblocking)
index 75e70f0965d073361392de156a7219a9845ab11f..e45dc7b6e2ce203d334e31c7c68f46f89da6a9f7 100644 (file)
@@ -878,14 +878,13 @@ bouquet_class_chtag_notify ( void *obj, const char *lang )
 static const void *
 bouquet_class_chtag_ref_get ( void *obj )
 {
-  static const char *buf;
   bouquet_t *bq = obj;
 
   if (bq->bq_chtag_ptr)
-    buf = idnode_uuid_as_str(&bq->bq_chtag_ptr->ct_id, prop_sbuf);
+    idnode_uuid_as_str(&bq->bq_chtag_ptr->ct_id, prop_sbuf);
   else
-    buf = "";
-  return &buf;
+    prop_sbuf[0] = '\0';
+  return &prop_sbuf_ptr;
 }
 
 static char *
index a8b3a00f02877b61fd74d2f72c2c9511d6a00657..5d2dc88348a0f622f783aa72b55b0277f79669b4 100644 (file)
@@ -213,9 +213,8 @@ channel_class_icon_notify ( void *obj, const char *lang )
 static const void *
 channel_class_get_icon ( void *obj )
 {
-  static const char *s;
-  s = channel_get_icon(obj);
-  return &s;
+  prop_ptr = channel_get_icon(obj);
+  return &prop_ptr;
 }
 
 static const char *
@@ -256,9 +255,8 @@ channel_class_set_name ( void *o, const void *p )
 static const void *
 channel_class_get_name ( void *o )
 {
-  static const char *s;
-  s = channel_get_name(o, channel_blank_name);
-  return &s;
+  prop_ptr = channel_get_name(o, channel_blank_name);
+  return &prop_ptr;
 }
 
 static const void *
@@ -1434,9 +1432,8 @@ channel_tag_class_icon_notify ( void *obj, const char *lang )
 static const void *
 channel_tag_class_get_icon ( void *obj )
 {
-  static const char *s;
-  s = channel_tag_get_icon(obj);
-  return &s;
+  prop_ptr = channel_tag_get_icon(obj);
+  return &prop_ptr;
 }
 
 /* exported for others */
index 97bb73b77c2c908ba9216348e2fe717f8981fe88..edc3210c1022fc787c4030147a3f49099d5e1711 100644 (file)
@@ -184,11 +184,11 @@ static const char *
 caclient_class_get_title ( idnode_t *in, const char *lang )
 {
   caclient_t *cac = (caclient_t *)in;
-  static char buf[32];
   if (cac->cac_name && cac->cac_name[0])
     return cac->cac_name;
-  snprintf(buf, sizeof(buf), tvh_gettext_lang(lang, N_("CA client %i")), cac->cac_index);
-  return buf;
+  snprintf(prop_sbuf, PROP_SBUF_LEN,
+           tvh_gettext_lang(lang, N_("CA client %i")), cac->cac_index);
+  return prop_sbuf;
 }
 
 static void
@@ -242,9 +242,8 @@ static const void *
 caclient_class_status_get(void *o)
 {
   caclient_t *cac = o;
-  static const char *ret;
-  ret = caclient_get_status(cac);
-  return &ret;
+  prop_ptr = caclient_get_status(cac);
+  return &prop_ptr;
 }
 
 CLASS_DOC(caclient)
index 5b96d14da6a730b6d50907ad03e3fc6a4d68f7b5..8bf7e83f0dba88485c1b43bb06d0949e74db68c8 100644 (file)
@@ -1886,9 +1886,7 @@ static const void *
 caclient_cccam_nodeid_get(void *o)
 {
   cccam_t *cccam = o;
-  static char buf[64];
-  static const char *ret = buf;
-  snprintf(buf, sizeof(buf),
+  snprintf(prop_sbuf, PROP_SBUF_LEN,
            "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
            cccam->cccam_nodeid[0x0],
            cccam->cccam_nodeid[0x1],
@@ -1898,7 +1896,7 @@ caclient_cccam_nodeid_get(void *o)
            cccam->cccam_nodeid[0x5],
            cccam->cccam_nodeid[0x6],
            cccam->cccam_nodeid[0x7]);
-  return &ret;
+  return &prop_sbuf_ptr;
 }
 
 
index 12b593c7f9d0ad41b82e0d3f8c5239afccc495a9..cd3aefefd5a85b5f6eb5a9be837100456e35350b 100644 (file)
@@ -261,15 +261,13 @@ constcw_class_key_odd_set(void *o, const void *v)
 static const void *
 constcw_class_key_get(void *o, const uint8_t *key)
 {
-  static char buf[64];
-  static const char *ret = buf;
   if (constcw_key_size(o) == 8) {
-    snprintf(buf, sizeof(buf),
+    snprintf(prop_sbuf, PROP_SBUF_LEN,
              "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
              key[0x0], key[0x1], key[0x2], key[0x3],
              key[0x4], key[0x5], key[0x6], key[0x7]);
   } else {
-    snprintf(buf, sizeof(buf),
+    snprintf(prop_sbuf, PROP_SBUF_LEN,
              "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:"
              "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
              key[0x0], key[0x1], key[0x2], key[0x3],
@@ -277,7 +275,7 @@ constcw_class_key_get(void *o, const uint8_t *key)
              key[0x8], key[0x9], key[0xa], key[0xb],
              key[0xc], key[0xd], key[0xe], key[0xf]);
   }
-  return &ret;
+  return &prop_sbuf_ptr;
 }
 
 static const void *
index 26af144d5b2853b14a7748597798b1a9d56ee350..826be59613c6f332bf852c60b7b2735e736c5f1d 100644 (file)
@@ -1812,9 +1812,7 @@ static const void *
 caclient_cwc_class_deskey_get(void *o)
 {
   cwc_t *cwc = o;
-  static char buf[64];
-  static const char *ret = buf;
-  snprintf(buf, sizeof(buf),
+  snprintf(prop_sbuf, PROP_SBUF_LEN,
            "%02x:%02x:%02x:%02x:%02x:%02x:%02x:"
            "%02x:%02x:%02x:%02x:%02x:%02x:%02x",
            cwc->cwc_confedkey[0x0],
@@ -1831,7 +1829,7 @@ caclient_cwc_class_deskey_get(void *o)
            cwc->cwc_confedkey[0xb],
            cwc->cwc_confedkey[0xc],
            cwc->cwc_confedkey[0xd]);
-  return &ret;
+  return &prop_sbuf_ptr;
 }
 
 const idclass_t caclient_cwc_class =
index 723d70de657de99d9a71d50f75de343ae94da84c..1eb628d1ea6282a4f388c9243850bf0a95596a51 100644 (file)
@@ -632,14 +632,11 @@ dvr_autorec_entry_class_start_window_set(void *o, const void *v)
 static const void *
 dvr_autorec_entry_class_time_get(void *o, int tm)
 {
-  static const char *ret;
-  static char buf[16];
   if (tm >= 0)
-    snprintf(buf, sizeof(buf), "%02d:%02d", tm / 60, tm % 60);
+    snprintf(prop_sbuf, PROP_SBUF_LEN, "%02d:%02d", tm / 60, tm % 60);
   else
-    strncpy(buf, N_("Any"), 16);
-  ret = buf;
-  return &ret;
+    strncpy(prop_sbuf, N_("Any"), 16);
+  return &prop_sbuf_ptr;
 }
 
 static const void *
@@ -852,13 +849,11 @@ dvr_autorec_entry_class_brand_set(void *o, const void *v)
 static const void *
 dvr_autorec_entry_class_brand_get(void *o)
 {
-  static const char *ret;
   dvr_autorec_entry_t *dae = (dvr_autorec_entry_t *)o;
-  if (dae->dae_brand)
-    ret = dae->dae_brand->uri;
-  else
-    ret = "";
-  return &ret;
+  prop_ptr = dae->dae_brand ? dae->dae_brand->uri : NULL;
+  if (prop_ptr == NULL)
+    prop_ptr = "";
+  return &prop_ptr;
 }
 
 static int
@@ -888,13 +883,11 @@ dvr_autorec_entry_class_season_set(void *o, const void *v)
 static const void *
 dvr_autorec_entry_class_season_get(void *o)
 {
-  static const char *ret;
   dvr_autorec_entry_t *dae = (dvr_autorec_entry_t *)o;
-  if (dae->dae_season)
-    ret = dae->dae_season->uri;
-  else
-    ret = "";
-  return &ret;
+  prop_ptr = dae->dae_season ? dae->dae_season->uri : NULL;
+  if (prop_ptr == NULL)
+    prop_ptr = "";
+  return &prop_ptr;
 }
 
 static int
@@ -924,13 +917,11 @@ dvr_autorec_entry_class_series_link_set(void *o, const void *v)
 static const void *
 dvr_autorec_entry_class_series_link_get(void *o)
 {
-  static const char *ret;
   dvr_autorec_entry_t *dae = (dvr_autorec_entry_t *)o;
-  if (dae->dae_serieslink)
-    ret = dae->dae_serieslink->uri;
-  else
-    ret = "";
-  return &ret;
+  prop_ptr = dae->dae_serieslink ? dae->dae_serieslink->uri : NULL;
+  if (prop_ptr == NULL)
+    prop_ptr = "";
+  return &prop_ptr;
 }
 
 static htsmsg_t *
index 012da9fd2730cc88902b13f4c4f36e68f01100cb..fb25c6cd42afc05eb3885eaea087d19c72262c9d 100644 (file)
@@ -2599,11 +2599,9 @@ dvr_entry_class_config_name_rend(void *o, const char *lang)
 static const void *
 dvr_entry_class_filename_get(void *o)
 {
-  static const char *ret;
   dvr_entry_t *de = (dvr_entry_t *)o;
-  const char *s = dvr_get_filename(de);
-  ret = s ?: "";
-  return &ret;
+  prop_ptr = dvr_get_filename(de) ?: "";
+  return &prop_ptr;
 }
 
 static int
@@ -2681,13 +2679,12 @@ dvr_entry_class_channel_name_set(void *o, const void *v)
 static const void *
 dvr_entry_class_channel_name_get(void *o)
 {
-  static const char *ret;
   dvr_entry_t *de = (dvr_entry_t *)o;
   if (de->de_channel)
-    ret = channel_get_name(de->de_channel, channel_blank_name);
+    prop_ptr = channel_get_name(de->de_channel, channel_blank_name);
   else
-    ret = de->de_channel_name;
-  return &ret;
+    prop_ptr = de->de_channel_name;
+  return &prop_ptr;
 }
 
 static int
@@ -2798,19 +2795,17 @@ dvr_entry_class_autorec_get(void *o)
 static const void *
 dvr_entry_class_autorec_caption_get(void *o)
 {
-  static const char *ret;
   dvr_entry_t *de = (dvr_entry_t *)o;
   dvr_autorec_entry_t *dae = de->de_autorec;
   if (dae) {
-    ret = prop_sbuf;
     snprintf(prop_sbuf, PROP_SBUF_LEN, "%s%s%s%s",
              dae->dae_name ?: "",
              dae->dae_comment ? " (" : "",
              dae->dae_comment,
              dae->dae_comment ? ")" : "");
   } else
-    ret = "";
-  return &ret;
+    prop_sbuf[0] = '\0';
+  return &prop_sbuf_ptr;
 }
 
 static int
@@ -2838,32 +2833,28 @@ dvr_entry_class_timerec_set(void *o, const void *v)
 static const void *
 dvr_entry_class_timerec_get(void *o)
 {
-  static const char *ret;
-  char ubuf[UUID_HEX_SIZE];
   dvr_entry_t *de = (dvr_entry_t *)o;
   if (de->de_timerec)
-    ret = idnode_uuid_as_str(&de->de_timerec->dte_id, ubuf);
+    idnode_uuid_as_str(&de->de_timerec->dte_id, prop_sbuf);
   else
-    ret = "";
-  return &ret;
+    prop_sbuf[0] = '\0';
+  return &prop_sbuf_ptr;
 }
 
 static const void *
 dvr_entry_class_timerec_caption_get(void *o)
 {
-  static const char *ret;
   dvr_entry_t *de = (dvr_entry_t *)o;
   dvr_timerec_entry_t *dte = de->de_timerec;
   if (dte) {
-    ret = prop_sbuf;
     snprintf(prop_sbuf, PROP_SBUF_LEN, "%s%s%s%s",
              dte->dte_name ?: "",
              dte->dte_comment ? " (" : "",
              dte->dte_comment,
              dte->dte_comment ? ")" : "");
   } else
-    ret = "";
-  return &ret;
+    prop_sbuf[0] = '\0';
+  return &prop_sbuf_ptr;
 }
 
 static int
@@ -2879,14 +2870,12 @@ dvr_entry_class_parent_set(void *o, const void *v)
 static const void *
 dvr_entry_class_parent_get(void *o)
 {
-  static const char *ret;
-  char ubuf[UUID_HEX_SIZE];
   dvr_entry_t *de = (dvr_entry_t *)o;
   if (de->de_parent)
-    ret = idnode_uuid_as_str(&de->de_parent->de_id, ubuf);
+    idnode_uuid_as_str(&de->de_parent->de_id, prop_sbuf);
   else
-    ret = "";
-  return &ret;
+    prop_sbuf[0] = '\0';
+  return &prop_sbuf_ptr;
 }
 
 static int
@@ -2902,14 +2891,12 @@ dvr_entry_class_child_set(void *o, const void *v)
 static const void *
 dvr_entry_class_child_get(void *o)
 {
-  static const char *ret;
-  char ubuf[UUID_HEX_SIZE];
   dvr_entry_t *de = (dvr_entry_t *)o;
   if (de->de_child)
-    ret = idnode_uuid_as_str(&de->de_child->de_id, ubuf);
+    idnode_uuid_as_str(&de->de_child->de_id, prop_sbuf);
   else
-    ret = "";
-  return &ret;
+    prop_sbuf[0] = '\0';
+  return &prop_sbuf_ptr;
 }
 
 static int
@@ -2957,14 +2944,13 @@ static const void *
 dvr_entry_class_disp_title_get(void *o)
 {
   dvr_entry_t *de = (dvr_entry_t *)o;
-  static const char *s;
-  s = "";
-  if (de->de_title) {
-    s = lang_str_get(de->de_title, idnode_lang(o));
-    if (s == NULL)
-      s = "";
-  }
-  return &s;
+  if (de->de_title)
+    prop_ptr = lang_str_get(de->de_title, idnode_lang(o));
+  else
+    prop_ptr = NULL;
+  if (prop_ptr == NULL)
+    prop_ptr = "";
+  return &prop_ptr;
 }
 
 static int
@@ -2988,28 +2974,26 @@ static const void *
 dvr_entry_class_disp_subtitle_get(void *o)
 {
   dvr_entry_t *de = (dvr_entry_t *)o;
-  static const char *s;
-  s = "";
-  if (de->de_subtitle) {
-    s = lang_str_get(de->de_subtitle, idnode_lang(o));
-    if (s == NULL)
-      s = "";
-  }
-  return &s;
+  if (de->de_subtitle)
+    prop_ptr = lang_str_get(de->de_subtitle, idnode_lang(o));
+  else
+    prop_ptr = NULL;
+  if (prop_ptr == NULL)
+    prop_ptr = "";
+  return &prop_ptr;
 }
 
 static const void *
 dvr_entry_class_disp_description_get(void *o)
 {
   dvr_entry_t *de = (dvr_entry_t *)o;
-  static const char *s;
-  s = "";
-  if (de->de_desc) {
-    s = lang_str_get(de->de_desc, idnode_lang(o));
-    if (s == NULL)
-      s = "";
-  }
-  return &s;
+  if (de->de_desc)
+    prop_ptr = lang_str_get(de->de_desc, idnode_lang(o));
+  else
+    prop_ptr = NULL;
+  if (prop_ptr == NULL)
+    prop_ptr = "";
+  return &prop_ptr;
 }
 
 static const void *
@@ -3076,24 +3060,18 @@ static const void *
 dvr_entry_class_status_get(void *o)
 {
   dvr_entry_t *de = (dvr_entry_t *)o;
-  static const char *s;
-  static char buf[100];
-  strncpy(buf, dvr_entry_status(de), sizeof(buf));
-  buf[sizeof(buf)-1] = '\0';
-  s = buf;
-  return &s;
+  strncpy(prop_sbuf, dvr_entry_status(de), PROP_SBUF_LEN);
+  prop_sbuf[PROP_SBUF_LEN-1] = '\0';
+  return &prop_sbuf_ptr;
 }
 
 static const void *
 dvr_entry_class_sched_status_get(void *o)
 {
   dvr_entry_t *de = (dvr_entry_t *)o;
-  static const char *s;
-  static char buf[100];
-  strncpy(buf, dvr_entry_schedstatus(de), sizeof(buf));
-  buf[sizeof(buf)-1] = '\0';
-  s = buf;
-  return &s;
+  strncpy(prop_sbuf, dvr_entry_schedstatus(de), PROP_SBUF_LEN);
+  prop_sbuf[PROP_SBUF_LEN-1] = '\0';
+  return &prop_sbuf_ptr;
 }
 
 static const void *
@@ -3101,13 +3079,14 @@ dvr_entry_class_channel_icon_url_get(void *o)
 {
   dvr_entry_t *de = (dvr_entry_t *)o;
   channel_t *ch = de->de_channel;
-  static const char *s;
   if (ch == NULL) {
-    s = "";
-  } else if ((s = channel_get_icon(ch)) == NULL) {
-    s = "";
+    prop_ptr = NULL;
+  } else {
+    prop_ptr = channel_get_icon(ch);
   }
-  return &s;
+  if (prop_ptr == NULL)
+    prop_ptr = "";
+  return &prop_ptr;
 }
 
 static const void *
index b3019ce6e240c573c81071d32d539b434b0f21c2..ae1ca683652ad419049934170321cb4d8d307e12 100644 (file)
@@ -88,14 +88,13 @@ dvr_timerec_purge_spawn(dvr_timerec_entry_t *dte, int delconf)
 static const char *
 dvr_timerec_title(dvr_timerec_entry_t *dte, struct tm *start)
 {
-  static char buf[256];
   size_t len;
 
   if (dte->dte_title == NULL)
     return _("Unknown");
-  len = strftime(buf, sizeof(buf) - 1, dte->dte_title, start);
-  buf[len] = '\0';
-  return buf;
+  len = strftime(prop_sbuf, PROP_SBUF_LEN-1, dte->dte_title, start);
+  prop_sbuf[len] = '\0';
+  return prop_sbuf;
 }
 
 /**
@@ -401,14 +400,11 @@ dvr_timerec_entry_class_stop_set(void *o, const void *v)
 static const void *
 dvr_timerec_entry_class_time_get(void *o, int tm)
 {
-  static const char *ret;
-  static char buf[16];
   if (tm >= 0)
-    snprintf(buf, sizeof(buf), "%02d:%02d", tm / 60, tm % 60);
+    snprintf(prop_sbuf, PROP_SBUF_LEN, "%02d:%02d", tm / 60, tm % 60);
   else
-    strncpy(buf, N_("Any"), 16);
-  ret = buf;
-  return &ret;
+    strncpy(prop_sbuf, N_("Any"), 16);
+  return &prop_sbuf_ptr;
 }
 
 static const void *
index f0e9207f0c6d288b1022c4ed6523fa4c46bfbfc7..1ad2e05a722c5737b6a3731bcb59f1abdaecae15 100644 (file)
@@ -281,13 +281,12 @@ linuxdvb_frontend_dvbs_class_satconf_set ( void *self, const void *str )
 static const void *
 linuxdvb_frontend_dvbs_class_satconf_get ( void *self )
 {
-  static const char *s;
   linuxdvb_frontend_t *lfe = self;
   if (lfe->lfe_satconf)
-    s = lfe->lfe_satconf->ls_type;
+    prop_ptr = lfe->lfe_satconf->ls_type;
   else
-    s = NULL;
-  return &s;
+    prop_ptr = NULL;
+  return &prop_ptr;
 }
 
 static htsmsg_t *
index 817d299772a6e5f161a39eb54806d38d86c8f80a..75944c3ec0efe851b5c831f917d6ebafc5ab5752 100644 (file)
@@ -1355,10 +1355,9 @@ linuxdvb_satconf_ele_class_lnbtype_set ( void *o, const void *p )
 static const void *
 linuxdvb_satconf_ele_class_lnbtype_get ( void *o )
 {
-  static const char *s;
   linuxdvb_satconf_ele_t *ls = o;
-  s = ls->lse_lnb ? ls->lse_lnb->ld_type : NULL;
-  return &s;
+  prop_ptr = ls->lse_lnb ? ls->lse_lnb->ld_type : NULL;
+  return &prop_ptr;
 }
 
 static int
@@ -1375,10 +1374,9 @@ linuxdvb_satconf_ele_class_en50494type_set ( void *o, const void *p )
 static const void *
 linuxdvb_satconf_ele_class_en50494type_get ( void *o )
 {
-  static const char *s;
   linuxdvb_satconf_ele_t *ls = o;
-  s = ls->lse_en50494 ? ls->lse_en50494->ld_type : NULL;
-  return &s;
+  prop_ptr = ls->lse_en50494 ? ls->lse_en50494->ld_type : NULL;
+  return &prop_ptr;
 }
 
 static int
@@ -1396,10 +1394,9 @@ linuxdvb_satconf_ele_class_switchtype_set ( void *o, const void *p )
 static const void *
 linuxdvb_satconf_ele_class_switchtype_get ( void *o )
 {
-  static const char *s;
   linuxdvb_satconf_ele_t *ls = o;
-  s = ls->lse_switch ? ls->lse_switch->ld_type : NULL;
-  return &s;
+  prop_ptr = ls->lse_switch ? ls->lse_switch->ld_type : NULL;
+  return &prop_ptr;
 }
 
 static int
@@ -1417,10 +1414,9 @@ linuxdvb_satconf_ele_class_rotortype_set ( void *o, const void *p )
 static const void *
 linuxdvb_satconf_ele_class_rotortype_get ( void *o )
 {
-  static const char *s;
   linuxdvb_satconf_ele_t *ls = o;
-  s = ls->lse_rotor ? ls->lse_rotor->ld_type : NULL;
-  return &s;
+  prop_ptr = ls->lse_rotor ? ls->lse_rotor->ld_type : NULL;
+  return &prop_ptr;
 }
 
 static const char *
index ebeb9e2e29ff086c262c7074e1b1ed249b746b26..9156f3722fcce89bc2c2f547e6e3b7acfc4cf6d1 100644 (file)
@@ -49,10 +49,9 @@ extern const idclass_t mpegts_mux_class;
 static const void * \
 dvb_mux_##c##_class_##l##_get (void *o)\
 {\
-  static const char *s;\
   dvb_mux_t *lm = o;\
-  s = dvb_##t##2str(lm->lm_tuning.dmc_fe_##f);\
-  return &s;\
+  prop_ptr = dvb_##t##2str(lm->lm_tuning.dmc_fe_##f);\
+  return &prop_ptr;\
 }\
 static int \
 dvb_mux_##c##_class_##l##_set (void *o, const void *v)\
@@ -77,10 +76,9 @@ dvb_mux_##c##_class_##l##_enum (void *o, const char *lang)\
 static const void * \
 dvb_mux_##c##_class_##l##_get (void *o)\
 {\
-  static const char *s;\
   dvb_mux_t *lm = o;\
-  s = dvb_##t##2str(lm->lm_tuning.u.dmc_fe_##f.p);\
-  return &s;\
+  prop_ptr = dvb_##t##2str(lm->lm_tuning.u.dmc_fe_##f.p);\
+  return &prop_ptr;\
 }\
 static int \
 dvb_mux_##c##_class_##l##_set (void *o, const void *v)\
@@ -113,10 +111,9 @@ dvb_mux_##c##_class_##l##_enum (void *o, const char *lang)\
 static const void *
 dvb_mux_class_delsys_get (void *o)
 {
-  static const char *s;
   dvb_mux_t *lm = o;
-  s = dvb_delsys2str(lm->lm_tuning.dmc_fe_delsys);
-  return &s;
+  prop_ptr = dvb_delsys2str(lm->lm_tuning.dmc_fe_delsys);
+  return &prop_ptr;
 }
 
 static int
index 5493318887cb279af1008718c19a40fdfd0d9ec6..745995644868e9f732d085c655b17c34bb56a9e3 100644 (file)
@@ -57,8 +57,8 @@ dvb_network_class_delete ( idnode_t *in )
 static const void *
 dvb_network_class_scanfile_get ( void *o )
 {
-  static const char *s = NULL;
-  return &s;
+  prop_ptr = NULL;
+  return &prop_ptr;
 }
 
 void
@@ -180,15 +180,10 @@ static const void *
 dvb_network_class_orbital_pos_get ( void *o )
 {
   dvb_network_t *ln = o;
-  static char buf[16];
-  static const char *s;
-  s = NULL;
-  if (ln->mn_satpos != INT_MAX) {
-    dvb_sat_position_to_str(ln->mn_satpos, buf, sizeof(buf));
-    s = buf;
-  } else
-    s = "";
-  return &s;
+  prop_sbuf[0] = '\0';
+  if (ln->mn_satpos != INT_MAX)
+    dvb_sat_position_to_str(ln->mn_satpos, prop_sbuf, PROP_SBUF_LEN);
+  return &prop_sbuf_ptr;
 }
 
 static int
index afee4fa008496575868668a480da36e8ebc51d3a..08ec072714ac3715356f59b374b92b85c0b89ef3 100644 (file)
@@ -26,7 +26,8 @@
 #include "lang_str.h"
 
 char prop_sbuf[PROP_SBUF_LEN];
-char *prop_sbuf_ptr = prop_sbuf;
+const char *prop_sbuf_ptr = prop_sbuf;
+const char *prop_ptr;
 
 /* **************************************************************************
  * Utilities
index d27752b3eea7c1000272cccf804ba308ec82cffb..922d1c7b15598f20e4dc3e89cc6c365ce7aca29e 100644 (file)
@@ -128,7 +128,8 @@ typedef struct property {
 
 #define PROP_SBUF_LEN 4096
 extern char prop_sbuf[PROP_SBUF_LEN];
-extern char *prop_sbuf_ptr;
+extern const char *prop_sbuf_ptr;
+extern const char *prop_ptr;
 
 const property_t *prop_find(const property_t *p, const char *name);