On 4/26/2017 3:31 AM, Andreas Dinter wrote:
Potential NULL pointer access in ip4_frag.c
Hi,
When compiling ip4_frag.c with GCC option -Wnull-dereference, it
complains with the following warning.
../../../lwIp/src/core/ipv4/ip4_frag.c:327:16: warning: potential null
pointer dereference [-Wnull-dereference]
This refers to this line:prev->next = ipr->next;
In function:ip_reass_dequeue_datagram()
I am using version 6.3.1 of GGC.
Can you please comment on this warning?
Not having access to that specific version of LwIP, I can only comment
on what the compiler is PROBABLY trying to warn you about. The only way
the compiler can KNOW you're not dereferencing a null pointer is for you
to check for null explicitly first, maybe something like this:
LWIP_ASSERT("sanity check linked list", prev != NULL);
*if ((prev == null) || (ipr == nu**ll)**
** return; // ignore if **either**of the pointers in null*
prev->next = ipr->next;
}
: : :
That would possibly get rid of your warning? (I think if LWIP_ASSERT
was enabled, the code generated by the macro expansion would be enough
to stop the warning, at least for 'prev'?)
Patrick
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users