This patch fixes a bug which was introduced in: e74d4244a285a7e29300c19df7b202ba7c51ecef The offending function was introduced in: 832ad693f5081b09a36d180f81c19be9092eb2e9 pa_modargs_get_samplerate() is not safe to be called if the modarg does not contain an entry with a "rate" key. pa_modargs_get_value_u32 returns 0 (success) if no value with the specified key is found, in this case the rate_local variable inside pa_modargs_get_samplerate() remains uninitialized. This patch modifies the pa_modargs_get_samplerate() function to modify the function argument rate. The function must now be called with an initialized rate argument. --- src/pulsecore/modargs.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/pulsecore/modargs.c b/src/pulsecore/modargs.c index 432e480..f3bf803 100644 --- a/src/pulsecore/modargs.c +++ b/src/pulsecore/modargs.c @@ -365,17 +365,13 @@ int pa_modargs_get_value_volume(pa_modargs *ma, const char *key, pa_volume_t *va } int pa_modargs_get_sample_rate(pa_modargs *ma, uint32_t *rate) { - uint32_t rate_local; - pa_assert(rate); - if ((pa_modargs_get_value_u32(ma, "rate", &rate_local)) < 0 || - rate_local <= 0 || - rate_local > PA_RATE_MAX) + if ((pa_modargs_get_value_u32(ma, "rate", rate)) < 0 || + *rate <= 0 || + *rate > PA_RATE_MAX) return -1; - *rate = rate_local; - return 0; } -- 1.8.5.1