[pulseaudio-discuss] [PATCH 02/10] tests: Fix potential out-of-bound access violation in svolume cpu-test

Peter Meerwald pmeerw at pmeerw.net
Wed Jan 30 02:03:57 PST 2013


From: Peter Meerwald <p.meerwald at bct-electronic.com>

nsamples should be forced to be a multiple of channels; do so correctly
and don't make nsamples larger than it actually is

Signed-off-by: Peter Meerwald <p.meerwald at bct-electronic.com>
---
 src/tests/cpu-test.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/tests/cpu-test.c b/src/tests/cpu-test.c
index 29e4770..f312edb 100644
--- a/src/tests/cpu-test.c
+++ b/src/tests/cpu-test.c
@@ -84,8 +84,8 @@ static void run_volume_test(pa_do_volume_func_t func, pa_do_volume_func_t orig_f
     samples_orig = s_orig + (8 - align);
     nsamples = SAMPLES - (8 - align);
     if (nsamples % channels)
-        nsamples += nsamples % channels;
-    size = nsamples * sizeof(*samples);
+        nsamples -= nsamples % channels;
+    size = nsamples * sizeof(int16_t);
 
     pa_random(samples, size);
     memcpy(samples_ref, samples, size);
-- 
1.7.9.5



More information about the pulseaudio-discuss mailing list