From 0762036bb3bcc04535568b9213c47490fc355469 Mon Sep 17 00:00:00 2001 From: lilong Date: Wed, 4 Jan 2023 14:49:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=BD=E6=95=B0StrToInt32=E5=86=85=E9=83=A8?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E8=8C=83=E5=9B=B4=E4=BB=A3=E7=A0=81=E6=97=A0?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gausskernel/optimizer/commands/copy.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gausskernel/optimizer/commands/copy.cpp b/src/gausskernel/optimizer/commands/copy.cpp index 27cc57c54..776253ab3 100644 --- a/src/gausskernel/optimizer/commands/copy.cpp +++ b/src/gausskernel/optimizer/commands/copy.cpp @@ -8442,6 +8442,7 @@ char* scan_dir(DIR* dir, const char* dirpath, const char* pattern, long* filesiz bool StrToInt32(const char* s, int *val) { /* set val to zero */ + int64 _val = 0; *val = 0; int base = 10; const char* ptr = s; @@ -8450,11 +8451,12 @@ bool StrToInt32(const char* s, int *val) if (isdigit((unsigned char)*ptr) == 0) return false; int8 digit = (*ptr++ - '0'); - *val = *val * base + digit; - if (*val > PG_INT32_MAX || *val < PG_INT32_MIN) { - return false; - } + _val = _val * base + digit; + if (_val > PG_INT32_MAX || _val < PG_INT32_MIN) { + return false; + } } + *val = (int)_val; return true; }