Backed out changeset 74312d99d538 (bug 1254061) for bustage. r=backout on a CLOSED TREE

This commit is contained in:
Sebastian Hengst 2016-03-21 19:15:49 +01:00
parent 1632fa76f2
commit 437ce2efda

View File

@ -294,25 +294,19 @@ nsHttp::FindToken(const char *input, const char *token, const char *seps)
bool
nsHttp::ParseInt64(const char *input, const char **next, int64_t *r)
{
MOZ_ASSERT(input);
MOZ_ASSERT(r);
char *end = nullptr;
errno = 0; // Clear errno to make sure its value is set by strtoll
int64_t value = strtoll(input, &end, /* base */ 10);
// Fail if: - the parsed number overflows.
// - the end points to the start of the input string.
// - we parsed a negative value. Consumers don't expect that.
if (errno != 0 || end == input || value < 0) {
LOG(("nsHttp::ParseInt64 value=%ld errno=%d", value, errno));
const char *start = input;
*r = 0;
while (*input >= '0' && *input <= '9') {
int64_t next = 10 * (*r) + (*input - '0');
if (next < *r) // overflow?
return false;
*r = next;
++input;
}
if (input == start) // nothing parsed?
return false;
}
if (next) {
*next = end;
}
*r = value;
if (next)
*next = input;
return true;
}