Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Nettle
nettle
Commits
0b0c2314
Commit
0b0c2314
authored
Jul 13, 2018
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Additional analogous assert in eratosthenese program.
parent
dd279150
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
2 deletions
+5
-2
ChangeLog
ChangeLog
+1
-0
examples/eratosthenes.c
examples/eratosthenes.c
+4
-2
No files found.
ChangeLog
View file @
0b0c2314
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
* examples/eratosthenes.c (vector_alloc): Add assert related to
* examples/eratosthenes.c (vector_alloc): Add assert related to
overflow in the size calculation. Fixes a corner case identified
overflow in the size calculation. Fixes a corner case identified
by static analysis.
by static analysis.
(vector_init): Analogous assert.
2018-07-12 Niels Möller <nisse@lysator.liu.se>
2018-07-12 Niels Möller <nisse@lysator.liu.se>
...
...
examples/eratosthenes.c
View file @
0b0c2314
...
@@ -111,8 +111,10 @@ vector_alloc(unsigned long size)
...
@@ -111,8 +111,10 @@ vector_alloc(unsigned long size)
static
void
static
void
vector_init
(
unsigned
long
*
vector
,
unsigned
long
size
)
vector_init
(
unsigned
long
*
vector
,
unsigned
long
size
)
{
{
unsigned
long
end
=
(
size
+
BITS_PER_LONG
-
1
)
/
BITS_PER_LONG
;
unsigned
long
end
,
i
;
unsigned
long
i
;
assert
(
size
<=
ULONG_MAX
-
(
BITS_PER_LONG
-
1
));
end
=
(
size
+
BITS_PER_LONG
-
1
)
/
BITS_PER_LONG
;
for
(
i
=
0
;
i
<
end
;
i
++
)
for
(
i
=
0
;
i
<
end
;
i
++
)
vector
[
i
]
=
~
0UL
;
vector
[
i
]
=
~
0UL
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment