diff --git a/src/pipewire/conf.c b/src/pipewire/conf.c index c29d45648..ef0f88717 100644 --- a/src/pipewire/conf.c +++ b/src/pipewire/conf.c @@ -918,8 +918,11 @@ static char **pw_strv_insert_at(char **strv, int len, int pos, const char *str) while (strv != NULL && strv[len] != NULL) len++; } - if (pos < 0 || pos > len) - pos = len+1; + + if (pos < 0) + pos = 0; + else if (pos > len) + pos = len; n = realloc(strv, sizeof(char*) * (len + 2)); if (n == NULL) {