mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-09-09 23:54:32 +00:00
Bugfix: correctly handle the case if uip_sappdata is NULL.
This commit is contained in:
parent
f31d6f271f
commit
d577d03e21
@ -2320,15 +2320,26 @@ uip_send(const void *data, int len)
|
||||
{
|
||||
int copylen;
|
||||
#define MIN(a,b) ((a) < (b)? (a): (b))
|
||||
|
||||
if(uip_sappdata != NULL) {
|
||||
copylen = MIN(len, UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN -
|
||||
(int)((char *)uip_sappdata - (char *)&uip_buf[UIP_LLH_LEN + UIP_TCPIP_HLEN]));
|
||||
(int)((char *)uip_sappdata -
|
||||
(char *)&uip_buf[UIP_LLH_LEN + UIP_TCPIP_HLEN]));
|
||||
} else {
|
||||
copylen = MIN(len, UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN);
|
||||
}
|
||||
if(copylen > 0) {
|
||||
uip_slen = copylen;
|
||||
if(data != uip_sappdata) {
|
||||
if(uip_sappdata == NULL) {
|
||||
memcpy((char *)&uip_buf[UIP_LLH_LEN + UIP_TCPIP_HLEN],
|
||||
(data), uip_slen);
|
||||
} else {
|
||||
memcpy(uip_sappdata, (data), uip_slen);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
Loading…
Reference in New Issue
Block a user