@@ -94,6 +94,12 @@ static WCHAR *wusername, *password, *protocol, *host, *path, target[1024];
9494static void write_item (const char * what , LPCWSTR wbuf , int wlen )
9595{
9696 char * buf ;
97+
98+ if (!wbuf || !wlen ) {
99+ printf ("%s=\n" , what );
100+ return ;
101+ }
102+
97103 int len = WideCharToMultiByte (CP_UTF8 , 0 , wbuf , wlen , NULL , 0 , NULL ,
98104 FALSE);
99105 buf = xmalloc (len );
@@ -160,7 +166,7 @@ static int match_part_last(LPCWSTR *ptarget, LPCWSTR want, LPCWSTR delim)
160166static int match_cred (const CREDENTIALW * cred )
161167{
162168 LPCWSTR target = cred -> TargetName ;
163- if (wusername && wcscmp (wusername , cred -> UserName ))
169+ if (wusername && wcscmp (wusername , cred -> UserName ? cred -> UserName : L"" ))
164170 return 0 ;
165171
166172 return match_part (& target , L"git" , L":" ) &&
@@ -183,7 +189,7 @@ static void get_credential(void)
183189 for (i = 0 ; i < num_creds ; ++ i )
184190 if (match_cred (creds [i ])) {
185191 write_item ("username" , creds [i ]-> UserName ,
186- wcslen (creds [i ]-> UserName ));
192+ creds [ i ] -> UserName ? wcslen (creds [i ]-> UserName ) : 0 );
187193 write_item ("password" ,
188194 (LPCWSTR )creds [i ]-> CredentialBlob ,
189195 creds [i ]-> CredentialBlobSize / sizeof (WCHAR ));
0 commit comments