@@ -400,11 +400,17 @@ static int winhttp_stream_connect(winhttp_stream *s)
400400 return -1 ;
401401 }
402402
403+ gitno_connection_data_free_ptrs (& t -> proxy_connection_data );
404+
403405 if ((error = gitno_extract_url_parts (& t -> proxy_connection_data .host , & t -> proxy_connection_data .port , NULL ,
404406 & t -> proxy_connection_data .user , & t -> proxy_connection_data .pass , proxy_url , NULL )) < 0 )
405407 goto on_error ;
406408
407409 if (t -> proxy_connection_data .user && t -> proxy_connection_data .pass ) {
410+ if (t -> proxy_cred ) {
411+ t -> proxy_cred -> free (t -> proxy_cred );
412+ }
413+
408414 if ((error = git_cred_userpass_plaintext_new (& t -> proxy_cred , t -> proxy_connection_data .user , t -> proxy_connection_data .pass )) < 0 )
409415 goto on_error ;
410416 }
@@ -425,10 +431,11 @@ static int winhttp_stream_connect(winhttp_stream *s)
425431 }
426432
427433 /* Convert URL to wide characters */
428- if ((error = git__utf8_to_16_alloc (& proxy_wide , processed_url .ptr )) < 0 )
434+ error = git__utf8_to_16_alloc (& proxy_wide , processed_url .ptr );
435+ git_buf_free (& processed_url );
436+ if (error < 0 )
429437 goto on_error ;
430438
431-
432439 proxy_info .dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY ;
433440 proxy_info .lpszProxy = proxy_wide ;
434441 proxy_info .lpszProxyBypass = NULL ;
@@ -1481,12 +1488,19 @@ static int winhttp_close(git_smart_subtransport *subtransport)
14811488
14821489 gitno_connection_data_free_ptrs (& t -> connection_data );
14831490 memset (& t -> connection_data , 0x0 , sizeof (gitno_connection_data ));
1491+ gitno_connection_data_free_ptrs (& t -> proxy_connection_data );
1492+ memset (& t -> proxy_connection_data , 0x0 , sizeof (gitno_connection_data ));
14841493
14851494 if (t -> cred ) {
14861495 t -> cred -> free (t -> cred );
14871496 t -> cred = NULL ;
14881497 }
14891498
1499+ if (t -> proxy_cred ) {
1500+ t -> proxy_cred -> free (t -> proxy_cred );
1501+ t -> proxy_cred = NULL ;
1502+ }
1503+
14901504 if (t -> url_cred ) {
14911505 t -> url_cred -> free (t -> url_cred );
14921506 t -> url_cred = NULL ;
0 commit comments