projects
/
platform
/
upstream
/
cmocka.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6a31004
)
cmocka: Allow test_free() to deal with NULL pointers.
author
Andreas Schneider
<asn@cryptomilk.org>
Fri, 6 Feb 2015 10:51:22 +0000
(11:51 +0100)
committer
Andreas Schneider
<asn@cryptomilk.org>
Sun, 8 Feb 2015 08:41:14 +0000
(09:41 +0100)
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
src/cmocka.c
patch
|
blob
|
history
diff --git
a/src/cmocka.c
b/src/cmocka.c
index
fe5faad
..
bac2ae5
100644
(file)
--- a/
src/cmocka.c
+++ b/
src/cmocka.c
@@
-1516,8
+1516,12
@@
void* _test_calloc(const size_t number_of_elements, const size_t size,
void _test_free(void* const ptr, const char* file, const int line) {
unsigned int i;
char *block = discard_const_p(char, ptr);
-
MallocBlockInfo *block_info;
+
+ if (ptr == NULL) {
+ return;
+ }
+
_assert_true(cast_ptr_to_largest_integral_type(ptr), "ptr", file, line);
block_info = (MallocBlockInfo*)(block - (MALLOC_GUARD_SIZE +
sizeof(*block_info)));