summaryrefslogtreecommitdiff
path: root/glib/gutils.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2005-07-10 04:44:27 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2005-07-10 04:44:27 +0000
commit35425ca9d6be66a9484c853435df23c8ddb6547b (patch)
tree18af2868875cf937dcde9a721dca1b44ae22c913 /glib/gutils.c
parent3baeda095b2d810c2c96e59b46a2d35667caefdd (diff)
downloadglib-35425ca9d6be66a9484c853435df23c8ddb6547b.tar.gz
Ignore anomalous environment entries which are not of the form
2005-07-10 Matthias Clasen <mclasen@redhat.com> * glib/gutils.c (g_listenv): Ignore anomalous environment entries which are not of the form variable=value. (#309859, Morten Welinder)
Diffstat (limited to 'glib/gutils.c')
-rw-r--r--glib/gutils.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/glib/gutils.c b/glib/gutils.c
index ffa8968c1..e59f280a1 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -1341,18 +1341,20 @@ gchar **
g_listenv (void)
{
gchar **result, *eq;
- gint len, i;
+ gint len, i, j;
len = g_strv_length (environ);
result = g_new0 (gchar *, len + 1);
+ j = 0;
for (i = 0; i < len; i++)
{
eq = strchr (environ[i], '=');
- result[i] = g_strndup (environ[i], eq - environ[i]);
+ if (eq)
+ result[j++] = g_strndup (environ[i], eq - environ[i]);
}
- result[len] = NULL;
+ result[j] = NULL;
return result;
}