Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nettle
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
5
Merge Requests
5
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Nettle
nettle
Commits
728a20ee
Commit
728a20ee
authored
Sep 16, 2012
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid calling libc realloc with a requested size of zero.
parent
3a73862a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
6 deletions
+22
-6
ChangeLog
ChangeLog
+4
-0
realloc.c
realloc.c
+18
-6
No files found.
ChangeLog
View file @
728a20ee
2012-09-16 Niels Möller <nisse@lysator.liu.se>
* realloc.c (nettle_realloc): Only call libc realloc if length >
0, otherwise call free. Fixes a small memory leak.
(nettle_xrealloc): Likewise.
* run-tests (test_program): Don't quote $EMULATOR; allow it to
expand to program and arguments (e.g., valgrind).
...
...
realloc.c
View file @
728a20ee
...
...
@@ -31,20 +31,32 @@
#include "realloc.h"
/* NOTE: Calling libc realloc with size == 0 is not required to
totally free the object, it is allowed to return a valid
pointer. */
void
*
nettle_realloc
(
void
*
ctx
UNUSED
,
void
*
p
,
unsigned
length
)
{
return
realloc
(
p
,
length
);
if
(
length
>
0
)
return
realloc
(
p
,
length
);
free
(
p
);
return
NULL
;
}
void
*
nettle_xrealloc
(
void
*
ctx
UNUSED
,
void
*
p
,
unsigned
length
)
{
void
*
n
=
realloc
(
p
,
length
);
if
(
length
&&
!
n
)
if
(
length
>
0
)
{
fprintf
(
stderr
,
"Virtual memory exhausted.
\n
"
);
abort
();
void
*
n
=
realloc
(
p
,
length
);
if
(
!
n
)
{
fprintf
(
stderr
,
"Virtual memory exhausted.
\n
"
);
abort
();
}
return
n
;
}
return
n
;
free
(
p
);
return
NULL
;
}
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