Bugfix: correctly handle the case if uip_sappdata is NULL.

This commit is contained in:
Adam Dunkels 2013-11-22 15:38:20 +01:00
parent f31d6f271f
commit d577d03e21

View file

@ -2320,14 +2320,25 @@ 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);
}
}
}
}
/*---------------------------------------------------------------------------*/
/** @} */