src: Set errno = 0 before calling strtol

This commit is contained in:
Tatsuhiro Tsujikawa 2014-01-18 15:32:50 +09:00
parent 67d4cb6367
commit 68b5204f29
4 changed files with 5 additions and 0 deletions

View File

@ -411,6 +411,7 @@ int main(int argc, char **argv)
break;
case 's':
/* --table-size */
errno = 0;
config.table_size = strtoul(optarg, &end, 10);
if(errno == ERANGE || *end != '\0') {
fprintf(stderr, "-s: Bad option value\n");
@ -419,6 +420,7 @@ int main(int argc, char **argv)
break;
case 'S':
/* --deflate-table-size */
errno = 0;
config.deflate_table_size = strtoul(optarg, &end, 10);
if(errno == ERANGE || *end != '\0') {
fprintf(stderr, "-S: Bad option value\n");

View File

@ -269,6 +269,7 @@ int main(int argc, char **argv)
exit(EXIT_SUCCESS);
case 's':
/* --table-size */
errno = 0;
config.table_size = strtoul(optarg, &end, 10);
if(errno == ERANGE || *end != '\0') {
fprintf(stderr, "-s: Bad option value\n");

View File

@ -1837,6 +1837,7 @@ int main(int argc, char **argv)
config.multiply = strtoul(optarg, nullptr, 10);
break;
case 'c':
errno = 0;
config.header_table_size = strtol(optarg, &end, 10);
if(errno == ERANGE || *end != '\0') {
std::cerr << "-c: Bad option value: " << optarg << std::endl;

View File

@ -167,6 +167,7 @@ int main(int argc, char **argv)
config.verbose = true;
break;
case 'c':
errno = 0;
config.header_table_size = strtol(optarg, &end, 10);
if(errno == ERANGE || *end != '\0') {
std::cerr << "-c: Bad option value: " << optarg << std::endl;