[pulseaudio-discuss] [PATCH v2 3/6] tests: Assert granularity range in stripnul.c

Peter Meerwald-Stadler pmeerw at pmeerw.net
Tue Aug 30 13:04:32 UTC 2016


granularity must not be larger than buffer size

CID 1138482
---
 src/tests/stripnul.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/tests/stripnul.c b/src/tests/stripnul.c
index 75390bd..e4b07aa 100644
--- a/src/tests/stripnul.c
+++ b/src/tests/stripnul.c
@@ -26,6 +26,8 @@
 #include <pulse/xmalloc.h>
 #include <pulsecore/macro.h>
 
+#define MAX_BUFFER (16*1024)
+
 int main(int argc, char *argv[]) {
     FILE *i, *o;
     size_t granularity;
@@ -34,13 +36,14 @@ int main(int argc, char *argv[]) {
 
     pa_assert_se(argc >= 2);
     pa_assert_se((granularity = (size_t) atoi(argv[1])) >= 1);
+    pa_assert(granularity <= MAX_BUFFER);
     pa_assert_se((i = (argc >= 3) ? fopen(argv[2], "r") : stdin));
     pa_assert_se((o = (argc >= 4) ? fopen(argv[3], "w") : stdout));
 
     zero = pa_xmalloc0(granularity);
 
     for (;;) {
-        uint8_t buffer[16*1024], *p;
+        uint8_t buffer[MAX_BUFFER], *p;
         size_t k;
 
         k = fread(buffer, granularity, sizeof(buffer)/granularity, i);
-- 
1.7.10.4



More information about the pulseaudio-discuss mailing list