From 5ade6a52d94f4accafef619ef0c44f4a60eadd34 Mon Sep 17 00:00:00 2001 From: obdev Date: Mon, 6 Jun 2022 14:22:48 +0800 Subject: [PATCH] [CP] Fix zero number exponent overflows --- deps/oblib/src/lib/number/ob_number_v2.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/deps/oblib/src/lib/number/ob_number_v2.cpp b/deps/oblib/src/lib/number/ob_number_v2.cpp index 2882096758..299d2e0844 100644 --- a/deps/oblib/src/lib/number/ob_number_v2.cpp +++ b/deps/oblib/src/lib/number/ob_number_v2.cpp @@ -363,7 +363,8 @@ int ObNumber::from_sci_(const char* str, const int64_t length, IAllocator& alloc nth += i_nth; } warning = OB_INVALID_NUMERIC; - } else if (0 == valid_len) { + } else if (0 == valid_len || 0 == i_nth) { + // `i_nth = 0` means all digits are zero. /* ignore e's value; only do the check*/ cur = str[++i]; if ('-' == cur || '+' == cur) { @@ -524,8 +525,9 @@ int ObNumber::from_sci_(const char* str, const int64_t length, IAllocator& alloc K(e_neg), K(e_value), K(valid_len), - K(i)); - if (as_zero || 0 == valid_len) { + K(i), + K(i_nth)); + if (as_zero || 0 == valid_len || 0 == i_nth) { full_str[0] = '0'; nth = 1; set_zero(); -- GitLab