]> 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:36:40 +0000 (09:36 +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

15 files changed:
src/access.c
src/bouquet.c
src/channels.c
src/descrambler/caclient.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 28a8ba42378efe1ad5bf4f3e341fb1ba98643941..d3ed8f70b7332cf3d0e432e819e0c50af3a80353 100644 (file)
@@ -1241,9 +1241,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
@@ -2164,9 +2163,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 a92379f3d054e401905ee4cf92cf1c3a725368c6..8e0f1693807f3b16faae4c3fd9cbc0e4ef548138 100644 (file)
@@ -866,14 +866,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 eabe134534c285943e718023aa7c36e55d53b31c..21aeea8def4e7c765851538e653e6484a548551b 100644 (file)
@@ -203,9 +203,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 *
@@ -246,9 +245,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);
-  return &s;
+  prop_str = channel_get_name(o);
+  return &prop_str;
 }
 
 static const void *
@@ -1418,9 +1416,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 eefd974599527aa3a14d491c5cc43a9825788adc..92d08a451a7c833df38778b49c53c47a276de502 100644 (file)
@@ -174,11 +174,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
@@ -232,9 +232,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 8117d2000b689489a98bd257bee0705dbdfe7187..06c3afb9d624eb035b276960d63c7c465b9ee75f 100644 (file)
@@ -245,15 +245,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],
@@ -261,7 +259,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 6bb785ea5761a235f41b5468f7ce290a576f84f8..d555b79dc6683c971ae5d76fd9e32fa32306f31a 100644 (file)
@@ -1810,9 +1810,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],
@@ -1829,7 +1827,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 290ebe004f5536acf2f42f0a65f6af11ce3025ea..152186d197159919d2438c71727d9030b292ec41 100644 (file)
@@ -620,14 +620,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 *
@@ -840,13 +837,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
@@ -876,13 +871,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
@@ -912,13 +905,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 fccb8b41b4a2c9868c18407c36380c6fbae9d519..93a3944b875ee0bf371f71d00490e5762c62fd42 100644 (file)
@@ -2583,11 +2583,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
@@ -2665,13 +2663,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);
+    prop_str = channel_get_name(de->de_channel);
   else
-    ret = de->de_channel_name;
-  return &ret;
+    prop_ptr = de->de_channel_name;
+  return &prop_ptr;
 }
 
 static int
@@ -2779,19 +2776,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
@@ -2819,32 +2814,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
@@ -2860,14 +2851,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
@@ -2883,14 +2872,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
@@ -2938,14 +2925,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
@@ -2969,28 +2955,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 *
@@ -3057,24 +3041,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 *
@@ -3082,13 +3060,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 c779969e9b55466394289edc95c3b50ff7038e82..0f7589ed83c4986fb5a0fe07265ed0fd35b0fe58 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;
 }
 
 /**
@@ -400,14 +399,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 50719bcaef6f6d1b06864376beed4eb8a9741d10..9679467cb35571eaae51d5c21bf15fc8a02f22ae 100644 (file)
@@ -251,13 +251,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 35bc57a1778dddb0a55bc6bfa07778ba7269c1c8..ff9898edd4c344ccc0c4fd8d14b7c39dead099b9 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 028a6200e876b97fca494243b1fd31daa05c886a..288f50ce6d408c99d6b0999d3c93e3d9f76d5f99 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 fb33d128ad8da81d1dc5cc967bf4d93fd5f0e3fa..ce78c57688ecce75b30e6b2e92aea425cadd76a9 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 c1f08372379cb5f4e72a37244b40c5907ea9389d..bb0291916db1dcae3f6df65aa2ce3112a1dd3189 100644 (file)
@@ -127,7 +127,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);