[vlc-commits] config_Get*Choices(): deal with empty strings (NULL) correctly

Rémi Denis-Courmont git at videolan.org
Fri Aug 24 13:22:46 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Aug 24 14:22:11 2012 +0300| [f4eb170d26a6d245fcf530b6598dd3c29521d40e] | committer: Rémi Denis-Courmont

config_Get*Choices(): deal with empty strings (NULL) correctly

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f4eb170d26a6d245fcf530b6598dd3c29521d40e
---

 src/config/core.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/config/core.c b/src/config/core.c
index 148d6ed..f7d59be 100644
--- a/src/config/core.c
+++ b/src/config/core.c
@@ -363,7 +363,8 @@ ssize_t config_GetIntChoices (vlc_object_t *obj, const char *name,
     {
         vals[i] = cfg->list.i[i];
         /* FIXME: use module_gettext() instead */
-        txts[i] = strdup (vlc_gettext (cfg->list_text[i]));
+        txts[i] = strdup ((cfg->list_text[i] != NULL)
+                                       ? vlc_gettext (cfg->list_text[i]) : "");
         if (unlikely(txts[i] == NULL))
             abort ();
     }
@@ -409,9 +410,10 @@ ssize_t config_GetPszChoices (vlc_object_t *obj, const char *name,
 
     for (size_t i = 0; i < count; i++)
     {
-        vals[i] = strdup (cfg->list.psz[i]);
+        vals[i] = strdup ((cfg->list.psz[i] != NULL) ? cfg->list.psz[i] : "");
         /* FIXME: use module_gettext() instead */
-        txts[i] = strdup (vlc_gettext(cfg->list_text[i]));
+        txts[i] = strdup ((cfg->list_text[i] != NULL)
+                                       ? vlc_gettext (cfg->list_text[i]) : "");
         if (unlikely(vals[i] == NULL || txts[i] == NULL))
             abort ();
     }



More information about the vlc-commits mailing list