Module: wine Branch: master Commit: e3a94656f2394c0ac0ec2a3be996a083ce124204 URL: http://source.winehq.org/git/wine.git/?a=commit;h=e3a94656f2394c0ac0ec2a3be9...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Tue Mar 25 08:04:45 2014 +0400
winhttp: Move allocation after input validation to fix leaks (Coverity).
---
dlls/winhttp/cookie.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/dlls/winhttp/cookie.c b/dlls/winhttp/cookie.c index af881ea..6e104b2 100644 --- a/dlls/winhttp/cookie.c +++ b/dlls/winhttp/cookie.c @@ -134,10 +134,6 @@ static cookie_t *parse_cookie( const WCHAR *string ) const WCHAR *p; int len;
- if (!(cookie = heap_alloc_zero( sizeof(cookie_t) ))) return NULL; - - list_init( &cookie->entry ); - if (!(p = strchrW( string, '=' ))) { WARN("no '=' in %s\n", debugstr_w(string)); @@ -148,6 +144,11 @@ static cookie_t *parse_cookie( const WCHAR *string ) WARN("empty cookie name in %s\n", debugstr_w(string)); return NULL; } + + if (!(cookie = heap_alloc_zero( sizeof(cookie_t) ))) return NULL; + + list_init( &cookie->entry ); + len = p - string; if (!(cookie->name = heap_alloc( (len + 1) * sizeof(WCHAR) ))) {