commit 3848c49d4beb04a8d8e6d7b027fe18f52dc18ea6
parent 6dfba29cb4054233ab6deb5fa81fb6023d82419e
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Fri, 8 Jul 2016 17:30:23 +0200
Fix an uninitialized memory issue
In C89 initializing the first element of an array to zero does not
ensure that the rest of the array is initialized to 0. Use memset
instead.
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/test_ssp_ran_uniform_disk.c b/src/test_ssp_ran_uniform_disk.c
@@ -32,6 +32,8 @@
#include "test_ssp_utils.h"
#include <rsys/math.h>
+#include <string.h>
+
#define NBS 1000000
int
@@ -46,7 +48,7 @@ main(int argc, char** argv)
double x = 0, x2 = 0;
double mean, std;
double exp_mean = 20 * 20 * NBS / (PI * 100 * 100 ), exp_std = 0;
- unsigned counts[10][10] = {0};
+ unsigned counts[10][10];
(void)argc, (void)argv;
mem_init_proxy_allocator(&allocator, &mem_default_allocator);
@@ -54,6 +56,7 @@ main(int argc, char** argv)
CHECK(ssp_rng_proxy_create(&allocator, &ssp_rng_threefry, 1, &proxy), RES_OK);
CHECK(ssp_rng_proxy_create_rng(proxy, 0, &rng), RES_OK);
+ memset(counts, 0, sizeof(counts));
for (i = 0; i < NBS; i++) {
ssp_ran_uniform_disk(rng, 100, pt);
/* locate pt in a 10x10 grid */