Commit 85d19dad authored by Dmitry Frank's avatar Dmitry Frank Committed by Cesanta Bot

Respect recv_mbuf_limit in lwip

PUBLISHED_FROM=470ff0f484bff3e4478651f0b64cc160bba8ebfc
parent c5cc4141
......@@ -15003,9 +15003,12 @@ static void mg_lwip_handle_recv_tcp(struct mg_connection *nc) {
#endif
mgos_lock();
while (cs->rx_chain != NULL) {
while (cs->rx_chain != NULL && nc->recv_mbuf.len < nc->recv_mbuf_limit) {
struct pbuf *seg = cs->rx_chain;
size_t len = (seg->len - cs->rx_offset);
size_t seg_len = (seg->len - cs->rx_offset);
size_t buf_avail = (nc->recv_mbuf_limit - nc->recv_mbuf.len);
size_t len = MIN(seg_len, buf_avail);
char *data = (char *) MG_MALLOC(len);
if (data == NULL) {
mgos_unlock();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment