From 92b6061929179a773d641e6dd0a679fa3ad2cb35 Mon Sep 17 00:00:00 2001 From: Catalin Patulea Date: Sun, 2 Mar 2014 21:47:28 -0500 Subject: [PATCH] upnphttp: check realloc return while receiving headers --- upnphttp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/upnphttp.c b/upnphttp.c index 68d168b..17e7dd3 100644 --- a/upnphttp.c +++ b/upnphttp.c @@ -1053,6 +1053,12 @@ Process_upnphttp(struct upnphttp * h) /* if 1st arg of realloc() is null, * realloc behaves the same as malloc() */ h->req_buf = (char *)realloc(h->req_buf, n + h->req_buflen + 1); + if (!h->req_buf) + { + DPRINTF(E_ERROR, L_HTTP, "Receive headers: %s\n", strerror(errno)); + h->state = 100; + break; + } memcpy(h->req_buf + h->req_buflen, buf, n); h->req_buflen += n; h->req_buf[h->req_buflen] = '\0';