Even stricted check in mg_to64()

This commit is contained in:
cpq 2021-03-21 16:14:44 +00:00
parent 9009cbc528
commit 0051f23e12
2 changed files with 2 additions and 2 deletions

View File

@ -4212,7 +4212,7 @@ int mg_asprintf(char **buf, size_t size, const char *fmt, ...) {
}
int64_t mg_to64(struct mg_str str) {
int64_t result = 0, neg = 1, max = 922337203685477580 /* INT64_MAX / 10 */;
int64_t result = 0, neg = 1, max = 922337203685477570 /* INT64_MAX/10-10 */;
size_t i = 0;
while (i < str.len && (str.ptr[i] == ' ' || str.ptr[i] == '\t')) i++;
if (i < str.len && str.ptr[i] == '-') neg = -1, i++;

View File

@ -262,7 +262,7 @@ int mg_asprintf(char **buf, size_t size, const char *fmt, ...) {
}
int64_t mg_to64(struct mg_str str) {
int64_t result = 0, neg = 1, max = 922337203685477580 /* INT64_MAX / 10 */;
int64_t result = 0, neg = 1, max = 922337203685477570 /* INT64_MAX/10-10 */;
size_t i = 0;
while (i < str.len && (str.ptr[i] == ' ' || str.ptr[i] == '\t')) i++;
if (i < str.len && str.ptr[i] == '-') neg = -1, i++;