diff options
author | Tom Briden <tom@decompile.me.uk> | 2022-05-15 12:15:26 +0300 |
---|---|---|
committer | Milo Yip <miloyip@gmail.com> | 2022-05-16 05:23:11 +0300 |
commit | 1f59c69cd18cd508395fe0bb5c2f8ee909e3c48d (patch) | |
tree | 8e5a5d3fe8b03d905fb37986075b351427619733 | |
parent | fcb23c2dbf561ec0798529be4f66394d3e4996d8 (diff) |
valuetest: fix potential write of terminating nul past the end of the destination
Fixes 2 compile errors with gcc-12, eg:
tesunittest/valuetest.cpp:1516:30: error: 'sprintf' may write a terminating nul past the end of the destination [-Werror=format-overflow=]
test/unittest/valuetest.cpp:1516:20: note: 'sprintf' output between 2 and 11 bytes into a destination of size 10
-rw-r--r-- | test/unittest/valuetest.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/test/unittest/valuetest.cpp b/test/unittest/valuetest.cpp index 0a6b325f..9211419a 100644 --- a/test/unittest/valuetest.cpp +++ b/test/unittest/valuetest.cpp @@ -1581,7 +1581,7 @@ TEST(Value, ObjectHelperRangeFor) { { int i = 0; for (auto& m : x.GetObject()) { - char name[10]; + char name[11]; sprintf(name, "%d", i); EXPECT_STREQ(name, m.name.GetString()); EXPECT_EQ(i, m.value.GetInt()); @@ -1592,7 +1592,7 @@ TEST(Value, ObjectHelperRangeFor) { { int i = 0; for (const auto& m : const_cast<const Value&>(x).GetObject()) { - char name[10]; + char name[11]; sprintf(name, "%d", i); EXPECT_STREQ(name, m.name.GetString()); EXPECT_EQ(i, m.value.GetInt()); |