@@ -44,15 +44,17 @@ static int extend_path(wchar_t *dir, size_t dir_len)
44
44
return 1 ;
45
45
}
46
46
47
- int WINAPI wWinMain (HINSTANCE instance , HINSTANCE previous_instance ,
48
- wchar_t * command_line , int show )
47
+ int WINAPI wWinMain (_In_ HINSTANCE instance ,
48
+ _In_opt_ HINSTANCE previous_instance ,
49
+ _In_ LPWSTR command_line , _In_ int show )
49
50
{
50
51
wchar_t git_command_line [32768 ];
51
52
size_t size = sizeof (git_command_line ) / sizeof (wchar_t );
52
53
const wchar_t * needs_quotes = L"" ;
53
54
int slash = 0 , i ;
54
55
55
56
STARTUPINFO startup_info = {
57
+ .cb = sizeof (STARTUPINFO ),
56
58
.dwFlags = STARTF_USESHOWWINDOW ,
57
59
.wShowWindow = SW_HIDE ,
58
60
};
@@ -68,7 +70,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE previous_instance,
68
70
else if (_wpgmptr [i ] == L'\\' )
69
71
slash = i ;
70
72
71
- if (slash + 11 >= sizeof ( git_command_line ) / sizeof ( wchar_t ) )
73
+ if (slash >= size - 11 )
72
74
return 127 ; /* Too long path */
73
75
74
76
/* If it is in Git's exec path, add the bin/ directory to the PATH */
@@ -88,8 +90,6 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE previous_instance,
88
90
return 127 ;
89
91
}
90
92
91
- startup_info .cb = sizeof (STARTUPINFO );
92
-
93
93
startup_info .hStdInput = GetStdHandle (STD_INPUT_HANDLE );
94
94
startup_info .hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE );
95
95
startup_info .hStdError = GetStdHandle (STD_ERROR_HANDLE );
@@ -105,10 +105,11 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE previous_instance,
105
105
& startup_info , & process_info ))
106
106
return 129 ; /* could not start */
107
107
WaitForSingleObject (process_info .hProcess , INFINITE );
108
- if (!GetExitCodeProcess (process_info .hProcess , & exit_code )) {
109
- CloseHandle (process_info .hProcess );
110
- return 130 ; /* Could not determine exit code? */
111
- }
108
+ if (!GetExitCodeProcess (process_info .hProcess , & exit_code ))
109
+ exit_code = 130 ; /* Could not determine exit code? */
110
+
111
+ CloseHandle (process_info .hProcess );
112
+ CloseHandle (process_info .hThread );
112
113
113
114
return (int )exit_code ;
114
115
}
0 commit comments