Free dynamically allocated memory before returning on errors
authorAdam Piątyszek <ediap@users.sourceforge.net>
Fri, 12 Feb 2010 21:45:19 +0000 (22:45 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 22 Feb 2010 13:59:54 +0000 (13:59 +0000)
Signed-off-by: Adam Piątyszek <ediap@users.sourceforge.net>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
http.c

diff --git a/http.c b/http.c
index 1b50f0f..5a98a6d 100644 (file)
--- a/http.c
+++ b/http.c
@@ -213,6 +213,7 @@ static int process_http_response(struct openconnect_info *vpninfo, int *result,
                        i = SSL_read(vpninfo->https_ssl, body + done, bodylen - done);
                        if (i < 0) {
                                vpninfo->progress(vpninfo, PRG_ERR, "Error reading HTTP response body\n");
+                                free(body);
                                return -EINVAL;
                        }
                        done += i;
@@ -238,6 +239,7 @@ static int process_http_response(struct openconnect_info *vpninfo, int *result,
                                i = SSL_read(vpninfo->https_ssl, body + done, chunklen);
                                if (i < 0) {
                                        vpninfo->progress(vpninfo, PRG_ERR, "Error reading HTTP response body\n");
+                                        free(body);
                                        return -EINVAL;
                                }
                                chunklen -= i;
@@ -251,9 +253,10 @@ static int process_http_response(struct openconnect_info *vpninfo, int *result,
                                        vpninfo->progress(vpninfo, PRG_ERR, "Error in chunked decoding. Expected '', got: '%s'",
                                                          buf);
                                }
+                                free(body);
                                return -EINVAL;
                        }
-                       
+
                        if (lastchunk)
                                break;
                }