diff --git a/src/core/init.c b/src/core/init.c index 5e0b522c..ea2d3d22 100644 --- a/src/core/init.c +++ b/src/core/init.c @@ -155,6 +155,9 @@ #if (MEM_USE_POOLS && !MEMP_USE_CUSTOM_POOLS) #error "MEM_USE_POOLS requires custom pools (MEMP_USE_CUSTOM_POOLS) to be enabled in your lwipopts.h" #endif +#if (PBUF_POOL_BUFSIZE <= MEM_ALIGNMENT) + #error "PBUF_POOL_BUFSIZE must be grater than MEM_ALIGNMENT or the offset may take the full first pbuf" +#endif /* Compile-time checks for deprecated options. diff --git a/src/core/pbuf.c b/src/core/pbuf.c index e1c28548..e860f69b 100644 --- a/src/core/pbuf.c +++ b/src/core/pbuf.c @@ -200,6 +200,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type) LWIP_ASSERT("check p->payload + p->len does not overflow pbuf", ((u8_t*)p->payload + p->len <= (u8_t*)p + SIZEOF_STRUCT_PBUF + PBUF_POOL_BUFSIZE_ALIGNED)); + LWIP_ASSERT("PBUF_POOL_BUFSIZE must be bigger than MEM_ALIGNMENT", p->len != 0); /* set reference count (needed here in case we fail) */ p->ref = 1;