basic: fix strv_env_get_n for unclean arrays

If an environment array has duplicates, strv_env_get_n returns
the results for the first match. This is wrong, because later
entries in the environment are supposed to replace earlier
entries.
This commit is contained in:
Ray Strode
2017-02-20 18:49:14 -05:00
committed by Zbigniew Jędrzejewski-Szmek
parent 1bd2d4e31b
commit 6162512cde
2 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -462,7 +462,7 @@ char *strv_env_get_n(char **l, const char *name, size_t k) {
if (k <= 0)
return NULL;
STRV_FOREACH(i, l)
STRV_FOREACH_BACKWARDS(i, l)
if (strneq(*i, name, k) &&
(*i)[k] == '=')
return *i + k + 1;