diff options
author | Lennart Poettering <lennart@poettering.net> | 2008-12-16 14:03:40 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2008-12-16 14:03:40 +0100 |
commit | 701384935446a5705cb77a9da2f896b086a392be (patch) | |
tree | 3c1cf45b3002d091652a10e0c11bafb9eec25b29 /src/pulsecore/proplist-util.c | |
parent | 2ee9276d97f15ea965fb8a88f2aa184355b9903a (diff) | |
download | pulseaudio-701384935446a5705cb77a9da2f896b086a392be.tar.gz |
Check if environ is actually set before we use it
Some applications seem to set **environ to NULL for various reasons.
Before we iterate through it we thus need to make sure it is actually
set to make sure we don't segfault.
Closes rhbz #473080
Diffstat (limited to 'src/pulsecore/proplist-util.c')
-rw-r--r-- | src/pulsecore/proplist-util.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/pulsecore/proplist-util.c b/src/pulsecore/proplist-util.c index 4d505f57b..35c9985af 100644 --- a/src/pulsecore/proplist-util.c +++ b/src/pulsecore/proplist-util.c @@ -44,27 +44,34 @@ void pa_init_proplist(pa_proplist *p) { pa_assert(p); - for (e = environ; *e; e++) { + if (environ) { - if (pa_startswith(*e, "PULSE_PROP_")) { - size_t kl = strcspn(*e+11, "="); - char *k; + /* Some applications seem to reset environ to NULL for various + * reasons, hence we need to check for this explicitly. See + * rhbz #473080 */ - if ((*e)[11+kl] != '=') - continue; + for (e = environ; *e; e++) { - if (!pa_utf8_valid(*e+11+kl+1)) - continue; + if (pa_startswith(*e, "PULSE_PROP_")) { + size_t kl = strcspn(*e+11, "="); + char *k; - k = pa_xstrndup(*e+11, kl); + if ((*e)[11+kl] != '=') + continue; - if (pa_proplist_contains(p, k)) { + if (!pa_utf8_valid(*e+11+kl+1)) + continue; + + k = pa_xstrndup(*e+11, kl); + + if (pa_proplist_contains(p, k)) { + pa_xfree(k); + continue; + } + + pa_proplist_sets(p, k, *e+11+kl+1); pa_xfree(k); - continue; } - - pa_proplist_sets(p, k, *e+11+kl+1); - pa_xfree(k); } } |