Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Poison freed memory objects
[vpp.git]
/
src
/
vppinfra
/
dlmalloc.c
diff --git
a/src/vppinfra/dlmalloc.c
b/src/vppinfra/dlmalloc.c
index
2199d87
..
1bc8f65
100644
(file)
--- a/
src/vppinfra/dlmalloc.c
+++ b/
src/vppinfra/dlmalloc.c
@@
-1745,6
+1745,7
@@
static int init_mparams(void) {
#endif
{
#endif
{
+#ifndef DLM_MAGIC_CONSTANT
#if USE_DEV_RANDOM
int fd;
unsigned char buf[sizeof(size_t)];
#if USE_DEV_RANDOM
int fd;
unsigned char buf[sizeof(size_t)];
@@
-1765,6
+1766,9
@@
static int init_mparams(void) {
#endif
magic |= (size_t)8U; /* ensure nonzero */
magic &= ~(size_t)7U; /* improve chances of fault for bad values */
#endif
magic |= (size_t)8U; /* ensure nonzero */
magic &= ~(size_t)7U; /* improve chances of fault for bad values */
+#else
+ magic = DLM_MAGIC_CONSTANT;
+#endif
/* Until memory modes commonly available, use volatile-write */
(*(volatile size_t *)(&(mparams.magic))) = magic;
}
/* Until memory modes commonly available, use volatile-write */
(*(volatile size_t *)(&(mparams.magic))) = magic;
}
@@
-4267,6
+4271,14
@@
void mspace_put (mspace msp, void *p_arg)
mheap_put_trace ((u64)p_arg, psize);
}
mheap_put_trace ((u64)p_arg, psize);
}
+#if CLIB_DEBUG > 0
+ /* Poison the object */
+ {
+ size_t psize = mspace_usable_size (object_header);
+ memset (object_header, 0x13, psize);
+ }
+#endif
+
/* And free it... */
mspace_free (msp, object_header);
}
/* And free it... */
mspace_free (msp, object_header);
}