Jacek Caban : wininet: Fix name and data allocation failure handling in alloc_cookie.

Alexandre Julliard julliard at winehq.org
Mon May 27 14:50:21 CDT 2019


Module: wine
Branch: master
Commit: 9fec2e0d9593726e3ebeca98defc5c9ab2d4b578
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=9fec2e0d9593726e3ebeca98defc5c9ab2d4b578

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon May 27 19:50:22 2019 +0200

wininet: Fix name and data allocation failure handling in alloc_cookie.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wininet/cookie.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/dlls/wininet/cookie.c b/dlls/wininet/cookie.c
index a1ea1de..30a9e25 100644
--- a/dlls/wininet/cookie.c
+++ b/dlls/wininet/cookie.c
@@ -238,7 +238,7 @@ static cookie_t *alloc_cookie(substr_t name, substr_t data, FILETIME expiry, FIL
 {
     cookie_t *new_cookie;
 
-    new_cookie = heap_alloc(sizeof(*new_cookie));
+    new_cookie = heap_alloc_zero(sizeof(*new_cookie));
     if(!new_cookie)
         return NULL;
 
@@ -247,9 +247,12 @@ static cookie_t *alloc_cookie(substr_t name, substr_t data, FILETIME expiry, FIL
     new_cookie->flags = flags;
     list_init(&new_cookie->entry);
 
-    new_cookie->name = heap_strndupW(name.str, name.len);
-    new_cookie->data = heap_strndupW(data.str, data.len);
-    if(!new_cookie->name || !new_cookie->data) {
+    if(name.str && !(new_cookie->name = heap_strndupW(name.str, name.len))) {
+        delete_cookie(new_cookie);
+        return NULL;
+    }
+
+    if(data.str && !(new_cookie->data = heap_strndupW(data.str, data.len))) {
         delete_cookie(new_cookie);
         return NULL;
     }




More information about the wine-cvs mailing list