[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] pbuf_realloc in ip.c problem
From: |
Martin Velek |
Subject: |
[lwip-users] pbuf_realloc in ip.c problem |
Date: |
Tue, 1 Sep 2009 09:44:09 +0200 |
Hello,
I am using lwip 1.3.1 with FreeRTOS and LM3S9B92. Because there is a
memory manager in the OS I have defined
#define MEM_LIBC_MALLOC 1
#define MEMP_MEM_MALLOC 1
#define MEM_USE_POOLS 0
with bget implementation of memory manager. All incomming packets are PBUF_RAM.
The lwip running fine until a tcp packet to port 80 is received(http
server by netconn). The lwip will cause a invalid memory access.
During debuging I have discovered that in file ip.c is called
pbuf_realloc(p, iphdr_len) and inside this function is called
mem_realloc(brel). Unfortunately bget reallocate memory by creating a
new space and than will free the old memory.
However this new memory is "lost" because the new pointer is not
stored. (q = mem_realloc(q, (u8_t *)q->payload - (u8_t *)q +
rem_len);) and q is not stored back to "p".
So, p is still pointing to the deallocated memory.
I have thought that the bget implementation is wrong but the standard
C's realloc returns:
"A pointer to the reallocated memory block, which may be either the
same as the ptr argument or a new location.
The type of this pointer is void*, which can be cast to the desired
type of data pointer in order to be dereferenceable.
If the function failed to allocate the requested block of memory, a
NULL pointer is returned."
Have anyone next similar problem?
Thank you for your reply.
Regards,
Martin Velek
- [lwip-users] pbuf_realloc in ip.c problem,
Martin Velek <=