Skip to content

Commit

Permalink
winhttp: Move allocation after input validation to fix leaks (Coverity).
Browse files Browse the repository at this point in the history
  • Loading branch information
nsivov authored and julliard committed Mar 25, 2014
1 parent c3f5fc5 commit e3a9465
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions dlls/winhttp/cookie.c
Expand Up @@ -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));
Expand All @@ -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) )))
{
Expand Down

0 comments on commit e3a9465

Please sign in to comment.