From 01532b0490de8249479e5fe0cca53419abd9cc71 Mon Sep 17 00:00:00 2001 From: Catalin Patulea Date: Sun, 2 Mar 2014 21:55:27 -0500 Subject: [PATCH] upnphttp: check realloc return while receiving request body --- upnphttp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/upnphttp.c b/upnphttp.c index 972a016..215cd4d 100644 --- a/upnphttp.c +++ b/upnphttp.c @@ -1098,6 +1098,12 @@ Process_upnphttp(struct upnphttp * h) buf[sizeof(buf)-1] = '\0'; /*fwrite(buf, 1, n, stdout);*/ /* debug */ h->req_buf = (char *)realloc(h->req_buf, n + h->req_buflen); + if (!h->req_buf) + { + DPRINTF(E_ERROR, L_HTTP, "Receive request body: %s\n", strerror(errno)); + h->state = 100; + break; + } memcpy(h->req_buf + h->req_buflen, buf, n); h->req_buflen += n; if((h->req_buflen - h->req_contentoff) >= h->req_contentlen)