From 645b2a70d17596eb16e6ad44aefd53e9e23caf4c Mon Sep 17 00:00:00 2001 From: chuaizhzh Date: Wed, 24 Mar 2021 18:16:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9Sscanf=E7=94=A8=E4=BE=8Bcrash?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I3ad8064485ced9689f1d13feb27d63d6d96af9cc --- kernel_lite/io_posix/src/IoTestSscanf.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel_lite/io_posix/src/IoTestSscanf.cpp b/kernel_lite/io_posix/src/IoTestSscanf.cpp index 74335540f..3bd29810b 100755 --- a/kernel_lite/io_posix/src/IoTestSscanf.cpp +++ b/kernel_lite/io_posix/src/IoTestSscanf.cpp @@ -151,9 +151,10 @@ HWTEST_F(IoTest, testSscanfChar, Function | MediumTest | Level1) EXPECT_EQ(ret, 1) << "> sscanf fail, errno = " << errno; EXPECT_EQ(c, 'a'); - ret = sscanf("hello", "%5c", &c); + char c2[10] = {0}; + ret = sscanf("helloworld", "%5c", c2); EXPECT_EQ(ret, 1) << "> sscanf fail, errno = " << errno; - EXPECT_EQ(c, 'h'); + EXPECT_EQ(c2, "hello"); ret = sscanf("(a) and |b|", "(%c) and |%c%*c|", &c, &c1); EXPECT_EQ(ret, 2) << "> sscanf fail, errno = " << errno; @@ -617,4 +618,4 @@ HWTEST_F(IoTest, testSscanfReturnValue, Function | MediumTest | Level1) EXPECT_EQ(ip[1], 11); EXPECT_EQ(ip[2], 11); EXPECT_EQ(ip[3], 0); -} \ No newline at end of file +} -- GitLab