mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-21 19:51:50 +00:00
Check UDP pbuf for being NULL
cesanta/mongoose-os#186 PUBLISHED_FROM=30460b56211eb0dff4d05bff45f256ac1da2caf4
This commit is contained in:
1 parent
fc113d64f5
commit
f20b5191f2
1 file changed
+4
@@ -14035,6 +14035,10 @@ void mg_lwip_if_udp_send(struct mg_connection *nc, const void *buf,
|
|||||||
struct pbuf *p = pbuf_alloc(PBUF_TRANSPORT, len, PBUF_RAM);
|
struct pbuf *p = pbuf_alloc(PBUF_TRANSPORT, len, PBUF_RAM);
|
||||||
ip_addr_t *ip = (ip_addr_t *) &nc->sa.sin.sin_addr.s_addr;
|
ip_addr_t *ip = (ip_addr_t *) &nc->sa.sin.sin_addr.s_addr;
|
||||||
u16_t port = ntohs(nc->sa.sin.sin_port);
|
u16_t port = ntohs(nc->sa.sin.sin_port);
|
||||||
|
if (p == NULL) {
|
||||||
|
DBG(("OOM"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
memcpy(p->payload, buf, len);
|
memcpy(p->payload, buf, len);
|
||||||
cs->err = udp_sendto(upcb, p, (ip_addr_t *) ip, port);
|
cs->err = udp_sendto(upcb, p, (ip_addr_t *) ip, port);
|
||||||
DBG(("%p udp_sendto = %d", nc, cs->err));
|
DBG(("%p udp_sendto = %d", nc, cs->err));
|
||||||
|
|||||||
Reference in new issue
Block a user