1
0
Fork 0

fix crashes

This commit is contained in:
jsteemann 2018-01-08 17:02:34 +01:00
parent 7f860153ba
commit f7e34b2d7c
2 changed files with 10 additions and 13 deletions

View File

@ -117,9 +117,9 @@ inline T atoi_negative(char const* p, char const* e, bool& valid) noexcept {
constexpr T cutoff = (std::numeric_limits<T>::min)() / 10;
constexpr char cutlim = -((std::numeric_limits<T>::min)() % 10);
T result = 0;
char c = *p;
do {
char c = *p;
// we expect only '0' to '9'. everything else is unexpected
if (TRI_UNLIKELY(c < '0' || c > '9')) {
valid = false;
@ -135,8 +135,7 @@ inline T atoi_negative(char const* p, char const* e, bool& valid) noexcept {
result *= 10;
result -= c;
++p;
c = *p;
} while (p < e);
} while (++p < e);
valid = true;
return result;
@ -161,9 +160,10 @@ inline T atoi_positive(char const* p, char const* e, bool& valid) noexcept {
constexpr T cutoff = (std::numeric_limits<T>::max)() / 10;
constexpr char cutlim = (std::numeric_limits<T>::max)() % 10;
T result = 0;
char c = *p;
do {
char c = *p;
// we expect only '0' to '9'. everything else is unexpected
if (TRI_UNLIKELY(c < '0' || c > '9')) {
valid = false;
@ -178,9 +178,7 @@ inline T atoi_positive(char const* p, char const* e, bool& valid) noexcept {
}
result *= 10;
result += c;
++p;
c = *p;
} while (p < e);
} while (++p < e);
valid = true;
return result;

View File

@ -75,9 +75,8 @@ TEST_CASE("LoggerTest", "[loggertest]") {
content = FileUtils::slurp(logfile2);
CHECK(content.find("some error message") == std::string::npos);
CHECK(content.find("some warning message") != std::string::npos);
}
SECTION("test_fdds_after_reopen") {
LogAppenderFile::clear();
}
SECTION("test_fds_after_reopen") {
@ -122,10 +121,10 @@ TEST_CASE("LoggerTest", "[loggertest]") {
CHECK(content.find("some error message") == std::string::npos);
CHECK(content.find("some warning message") == std::string::npos);
CHECK(content.find("some other warning message") != std::string::npos);
LogAppenderFile::clear();
}
LogAppenderFile::clear();
// restore old state
LogAppenderFile::setFds(backup);
LogAppenderFile::reopenAll();