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