Handle allocation failure in HTTP 1.0 loop
authorDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 22 Feb 2010 14:09:25 +0000 (14:09 +0000)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 22 Feb 2010 14:09:25 +0000 (14:09 +0000)
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
http.c

diff --git a/http.c b/http.c
index 2072001..2084e88 100644 (file)
--- a/http.c
+++ b/http.c
@@ -269,9 +269,13 @@ static int process_http_response(struct openconnect_info *vpninfo, int *result,
                /* HTTP 1.0 response. Just eat all we can in 16KiB chunks */
                while (1) {
                        body = realloc(body, done + 16384);
+                       if (!body)
+                               return -ENOMEM;
                        i = SSL_read(vpninfo->https_ssl, body + done, 16384);
                        if (i <= 0) {
                                body = realloc(body, done + 1);
+                               if (!body)
+                                       return -ENOMEM;
                                break;
                         }
                        done += i;