diff options
| author | Julien | 2011-06-04 07:00:24 +0800 | 
|---|---|---|
| committer | Julien | 2011-06-23 15:11:36 +0800 | 
| commit | 979fc29be615fa11a095d59adf37d4077018983c (patch) | |
| tree | 6f58355378c63e15a6178ff8c6c3e58e614582b6 | |
| parent | c52cc849123ac4a6e4a6ce1f0880cb1cd95e23cd (diff) | |
| download | scummvm-rg350-979fc29be615fa11a095d59adf37d4077018983c.tar.gz scummvm-rg350-979fc29be615fa11a095d59adf37d4077018983c.tar.bz2 scummvm-rg350-979fc29be615fa11a095d59adf37d4077018983c.zip  | |
BASE: Check return value from strtol in DO_OPTION_INT macro
| -rw-r--r-- | base/commandLine.cpp | 5 | 
1 files changed, 3 insertions, 2 deletions
diff --git a/base/commandLine.cpp b/base/commandLine.cpp index 61853a1ebc..6d187ac8b1 100644 --- a/base/commandLine.cpp +++ b/base/commandLine.cpp @@ -267,8 +267,9 @@ void registerDefaults() {  #define DO_OPTION_INT(shortCmd, longCmd) \  	DO_OPTION(shortCmd, longCmd) \  	char *endptr = 0; \ -	strtol(option, &endptr, 0); \ -	if (endptr == NULL || *endptr != 0) usage("--%s: Invalid number '%s'", longCmd, option); +	long int retval = strtol(option, &endptr, 0); \ +	if (endptr == NULL || *endptr != 0 || retval == 0 || retval == LONG_MAX || retval == LONG_MIN || errno == ERANGE) \ +		usage("--%s: Invalid number '%s'", longCmd, option);  // Use this for boolean options; this distinguishes between "-x" and "-X",  // resp. between "--some-option" and "--no-some-option".  | 
