Add check for chunk minsize
diff --git a/preload.c b/preload.c
index 45d4a37..4834036 100644
--- a/preload.c
+++ b/preload.c
@@ -49,7 +49,7 @@
};
#define CHUNK_SIZE (sizeof(struct malloc_chunk_head))
-#define MIN_CHUNK 0x10
+#define MIN_CHUNK 0x20
#define CHUNK_ALIGNMENT (MIN_CHUNK - 1)
struct segptr {
@@ -233,6 +233,13 @@
void __attribute__ ((constructor)) preload_setup(void)
{
+ /*
+ * if this fails, the MIN_CHUNK, which must be a power of 2
+ * isn't big enough. If that happens, chunk splitting will
+ * fail because the free list pointers get overwritten by the
+ * split
+ */
+ ASSERT(sizeof(struct malloc_chunk) < MIN_CHUNK);
if (getenv("MALLOC_DEBUG") != NULL)
debug = 1;
if (getenv("NO_SECRET_MEM") != NULL)