aboutsummaryrefslogtreecommitdiff
path: root/win32/lib/crt1.c
diff options
context:
space:
mode:
authorCarlos Montiers <carlos@thefunsouth.com>2014-07-16 22:22:05 -0400
committerCarlos Montiers <carlos@thefunsouth.com>2014-07-16 22:22:05 -0400
commit7c474b4da316a203938b3632ae5a87ad78c86776 (patch)
tree06ada6977635b43d9e7537e7e6404fa83d0f3dd3 /win32/lib/crt1.c
parentf2ee6b1759af005a060d638676a3e12ab8e42f9d (diff)
downloadtinycc-7c474b4da316a203938b3632ae5a87ad78c86776.tar.gz
tinycc-7c474b4da316a203938b3632ae5a87ad78c86776.tar.bz2
__getmainargs return int, not void, and on error, it return -1 and let argv untouched, also argc. Added a if checking the result of it.
Diffstat (limited to 'win32/lib/crt1.c')
-rw-r--r--win32/lib/crt1.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/win32/lib/crt1.c b/win32/lib/crt1.c
index 3e1d17f..bb92ba4 100644
--- a/win32/lib/crt1.c
+++ b/win32/lib/crt1.c
@@ -14,7 +14,7 @@ typedef struct
int newmode;
} _startupinfo;
-void __getmainargs(int *pargc, char ***pargv, char ***penv, int globb, _startupinfo*);
+int __getmainargs(int *pargc, char ***pargv, char ***penv, int globb, _startupinfo*);
int main(int argc, char **argv, char **env);
int _start(void)
@@ -25,7 +25,12 @@ int _start(void)
_controlfp(0x10000, 0x30000);
__set_app_type(__CONSOLE_APP);
- __getmainargs(&argc, &argv, &env, 0, &start_info);
+ if (__getmainargs(&argc, &argv, &env, 0, &start_info)) {
+ // __getmainargs failed because possible few memory on the heap.
+ fprintf(stderr, "Error getting the main args.");
+ // terminate with exit code of 3, similar to abort()
+ ExitProcess(3);
+ }
ret = main(argc, argv, env);
exit(ret);