Function _(w)setargv() provided by the application itself (not by the CRT
DLL runtime library) can fail, which is indicated by the return value.

Check for this failure and call _amsg_exit(_RT_SPACEARG) on error. Same
behavior has Visual C++ startup code.
---
 mingw-w64-crt/crt/crtexe.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/mingw-w64-crt/crt/crtexe.c b/mingw-w64-crt/crt/crtexe.c
index ec7fa74dc37b..4f058a8e1f5f 100644
--- a/mingw-w64-crt/crt/crtexe.c
+++ b/mingw-w64-crt/crt/crtexe.c
@@ -95,6 +95,7 @@ __mingw_invalidParameterHandler (const wchar_t * 
__UNUSED_PARAM_1(expression),
 static int __cdecl
 pre_c_init (void)
 {
+  int ret;
   managedapp = check_managed_app ();
   if (__mingw_app_type)
     __set_app_type(_GUI_APP);
@@ -105,10 +106,12 @@ pre_c_init (void)
   * __p__commode() = _commode;
 
 #ifdef _UNICODE
-  _wsetargv();
+  ret = _wsetargv();
 #else
-  _setargv();
+  ret = _setargv();
 #endif
+  if (ret < 0)
+    _amsg_exit(8); /* _RT_SPACEARG */
   if (_MINGW_INSTALL_DEBUG_MATHERR == 1)
     {
       __setusermatherr (_matherr);
-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to