[PATCH 2/2] modargs: Do not modify alternate_rate in pa_modargs_get_alternate_sample_rate() on failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Peter Meerwald <p.meerwald@xxxxxxxxxxxxxxxxxx>

Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
---
 src/pulsecore/modargs.c |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/pulsecore/modargs.c b/src/pulsecore/modargs.c
index 6855b6a..51e5501 100644
--- a/src/pulsecore/modargs.c
+++ b/src/pulsecore/modargs.c
@@ -411,15 +411,21 @@ int pa_modargs_get_sample_spec(pa_modargs *ma, pa_sample_spec *rss) {
 }
 
 int pa_modargs_get_alternate_sample_rate(pa_modargs *ma, uint32_t *alternate_rate) {
-    pa_assert(ma);
+    uint32_t rate_local;
+
     pa_assert(alternate_rate);
 
-    if ((pa_modargs_get_value_u32(ma, "alternate_rate", alternate_rate)) < 0 ||
-        *alternate_rate <= 0 ||
-        *alternate_rate > PA_RATE_MAX ||
-        !((*alternate_rate % 4000 == 0) || (*alternate_rate % 11025 == 0)))
+    rate_local = *alternate_rate;
+    if ((pa_modargs_get_value_u32(ma, "alternate_rate", &rate_local)) < 0 ||
+        rate_local <= 0 ||
+        rate_local > PA_RATE_MAX)
+        return -1;
+
+    if (!((rate_local % 4000 == 0) || (rate_local % 11025 == 0)))
         return -1;
 
+    *alternate_rate = rate_local;
+
     return 0;
 }
 
-- 
1.7.9.5



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux