Bugfix: correctly handle the case if uip_sappdata is NULL.
This commit is contained in:
parent
f31d6f271f
commit
d577d03e21
1 changed files with 14 additions and 3 deletions
|
@ -2320,14 +2320,25 @@ uip_send(const void *data, int len)
|
||||||
{
|
{
|
||||||
int copylen;
|
int copylen;
|
||||||
#define MIN(a,b) ((a) < (b)? (a): (b))
|
#define MIN(a,b) ((a) < (b)? (a): (b))
|
||||||
|
|
||||||
|
if(uip_sappdata != NULL) {
|
||||||
copylen = MIN(len, UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN -
|
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) {
|
if(copylen > 0) {
|
||||||
uip_slen = copylen;
|
uip_slen = copylen;
|
||||||
if(data != uip_sappdata) {
|
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);
|
memcpy(uip_sappdata, (data), uip_slen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
Loading…
Add table
Reference in a new issue