diff options
author | Niels Möller <nisse@lysator.liu.se> | 2018-07-13 20:18:46 +0200 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2018-07-13 20:18:46 +0200 |
commit | 0b0c23141d82a04ff9cc4815524c6e4a55434039 (patch) | |
tree | 27c3772bff49f3d1074c9d50aae8e62a02bb7f6f /examples | |
parent | dd279150dca790876e4531521c389f795561e39c (diff) | |
download | nettle-0b0c23141d82a04ff9cc4815524c6e4a55434039.tar.gz |
Additional analogous assert in eratosthenese program.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/eratosthenes.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/examples/eratosthenes.c b/examples/eratosthenes.c index 35f84e1c..38574778 100644 --- a/examples/eratosthenes.c +++ b/examples/eratosthenes.c @@ -111,8 +111,10 @@ vector_alloc(unsigned long size) static void vector_init(unsigned long *vector, unsigned long size) { - unsigned long end = (size + BITS_PER_LONG - 1) / BITS_PER_LONG; - unsigned long i; + unsigned long end, i; + + assert (size <= ULONG_MAX - (BITS_PER_LONG - 1)); + end = (size + BITS_PER_LONG - 1) / BITS_PER_LONG; for (i = 0; i < end; i++) vector[i] = ~0UL; |