Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Nettle
nettle
Commits
0355cfad
Commit
0355cfad
authored
Jul 12, 2018
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix at-exit leak in eratosthenes program.
parent
af7d1d76
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
ChangeLog
ChangeLog
+3
-0
examples/eratosthenes.c
examples/eratosthenes.c
+3
-2
No files found.
ChangeLog
View file @
0355cfad
2018-07-12 Niels Möller <nisse@lysator.liu.se>
* examples/eratosthenes.c (main): Don't allocate bitmap storage
for limit == 2 (early exit), closing memory leak at exit.
* eccdata.c (output_curve): Replace mpz_init_set_ui by mpz_set_ui,
to fix memory leak.
(ecc_curve_clear): New function.
...
...
examples/eratosthenes.c
View file @
0355cfad
...
...
@@ -314,8 +314,6 @@ main (int argc, char **argv)
root
=
(
root
-
1
)
|
1
;
/* Represents odd numbers from 3 up. */
sieve_nbits
=
(
root
-
1
)
/
2
;
sieve
=
vector_alloc
(
sieve_nbits
);
vector_init
(
sieve
,
sieve_nbits
);
if
(
verbose
)
fprintf
(
stderr
,
"Initial sieve using %lu bits.
\n
"
,
sieve_nbits
);
...
...
@@ -326,6 +324,9 @@ main (int argc, char **argv)
if
(
limit
==
2
)
return
EXIT_SUCCESS
;
sieve
=
vector_alloc
(
sieve_nbits
);
vector_init
(
sieve
,
sieve_nbits
);
for
(
bit
=
0
;
bit
<
sieve_nbits
;
bit
=
vector_find_next
(
sieve
,
bit
+
1
,
sieve_nbits
))
...
...
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