@@ -58,11 +58,9 @@ extern void __main(void);
5858static _TCHAR * * argv ;
5959static _TCHAR * * envp ;
6060
61- static int argret ;
6261static int mainret = 0 ;
6362static int managedapp ;
6463static int has_cctor = 0 ;
65- static _startupinfo startinfo ;
6664extern LPTOP_LEVEL_EXCEPTION_FILTER __mingw_oldexcpt_handler ;
6765
6866extern void _pei386_runtime_relocator (void );
@@ -97,6 +95,7 @@ __mingw_invalidParameterHandler (const wchar_t * __UNUSED_PARAM_1(expression),
9795static int __cdecl
9896pre_c_init (void )
9997{
98+ int ret ;
10099 managedapp = check_managed_app ();
101100 if (__mingw_app_type )
102101 __set_app_type (_GUI_APP );
@@ -107,10 +106,12 @@ pre_c_init (void)
107106 * __p__commode () = _commode ;
108107
109108#ifdef _UNICODE
110- _wsetargv ();
109+ ret = _wsetargv ();
111110#else
112- _setargv ();
111+ ret = _setargv ();
113112#endif
113+ if (ret < 0 )
114+ _amsg_exit (8 ); /* _RT_SPACEARG */
114115 if (_MINGW_INSTALL_DEBUG_MATHERR == 1 )
115116 {
116117 __setusermatherr (_matherr );
@@ -125,13 +126,18 @@ pre_c_init (void)
125126static void __cdecl
126127pre_cpp_init (void )
127128{
129+ _startupinfo startinfo ;
130+ int argret ;
131+
128132 startinfo .newmode = _newmode ;
129133
130134#ifdef _UNICODE
131135 argret = __wgetmainargs (& argc ,& argv ,& envp ,_dowildcard ,& startinfo );
132136#else
133137 argret = __getmainargs (& argc ,& argv ,& envp ,_dowildcard ,& startinfo );
134138#endif
139+ if (argret < 0 )
140+ _amsg_exit (8 ); /* _RT_SPACEARG */
135141}
136142
137143static int __tmainCRTStartup (void );
@@ -197,7 +203,7 @@ int mainCRTStartup (void)
197203static
198204#if defined(__i386__ ) || defined(_X86_ )
199205/* We need to make sure that we align the stack to 16 bytes for the sake of SSE
200- opts in main or in functions called main. */
206+ opts in main or in functions called from main. */
201207__attribute__((force_align_arg_pointer ))
202208#endif
203209__declspec(noinline ) int
@@ -223,7 +229,8 @@ __tmainCRTStartup (void)
223229 else if (__native_startup_state == __uninitialized )
224230 {
225231 __native_startup_state = __initializing ;
226- _initterm ((_PVFV * )(void * )__xi_a , (_PVFV * )(void * ) __xi_z );
232+ if (_initterm_e (__xi_a , __xi_z ) != 0 )
233+ return 255 ;
227234 }
228235 else
229236 has_cctor = 1 ;
0 commit comments