Check for alloc failure in cookie addition
authorDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 6 Nov 2009 11:16:22 +0000 (11:16 +0000)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 6 Nov 2009 11:16:22 +0000 (11:16 +0000)
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
http.c

diff --git a/http.c b/http.c
index 1af5473..c96aa04 100644 (file)
--- a/http.c
+++ b/http.c
@@ -62,6 +62,12 @@ int http_add_cookie(struct openconnect_info *vpninfo, const char *option, const
                new->next = NULL;
                new->option = strdup(option);
                new->value = strdup(value);
+               if (!new->option || !new->value) {
+                       free(new->option);
+                       free(new->value);
+                       free(new);
+                       return -ENOMEM;
+               }
        } else {
                /* Kill cookie; don't replace it */
                new = NULL;