Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorIlya Zverev <zverik@textual.ru>2016-05-31 19:30:10 +0300
committerIlya Zverev <zverik@textual.ru>2016-05-31 19:30:10 +0300
commit5b9dc0d5e8cfe6daeb74552e20d8a6ca2babcc77 (patch)
tree7d9ab59b9de9015d0fa9358ea4cce17bb66e6605 /base
parentd8a211aabd8b74f68036fd88afabf0e8dec08486 (diff)
[utils] Fix error checking in to_int
Diffstat (limited to 'base')
-rw-r--r--base/string_utils.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/base/string_utils.cpp b/base/string_utils.cpp
index de986d77a3..cd9a1101ad 100644
--- a/base/string_utils.cpp
+++ b/base/string_utils.cpp
@@ -59,6 +59,7 @@ bool IntegerCheck(char const * start, char const * stop, T x, TResult & out)
bool to_int(char const * start, int & i, int base /*= 10*/)
{
char * stop;
+ errno = 0; // Library functions do not reset it.
long const v = strtol(start, &stop, base);
return IntegerCheck(start, stop, v, i);
}
@@ -66,6 +67,7 @@ bool to_int(char const * start, int & i, int base /*= 10*/)
bool to_uint(char const * start, unsigned int & i, int base /*= 10*/)
{
char * stop;
+ errno = 0; // Library functions do not reset it.
unsigned long const v = strtoul(start, &stop, base);
return IntegerCheck(start, stop, v, i);
}