mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-09 16:41:18 +08:00
libstdc++: Fix buffer overflows in tests [PR 99382]
This seems to be a typo/thinko in the definition of the arrays used as storage. libstdc++-v3/ChangeLog: PR libstdc++/99382 * testsuite/20_util/specialized_algorithms/uninitialized_default_n/sizes.cc: Make storage larger than required. Verify no write to the last element. * testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/sizes.cc: Likewise.
This commit is contained in:
parent
f65e551f73
commit
905ce0ca30
@ -41,10 +41,12 @@ test02()
|
||||
int operator>(void*) { return value != 0; }
|
||||
};
|
||||
|
||||
int i[3];
|
||||
int i[5] = { 1, 2, 3, 4, 5 };
|
||||
Size n = {4};
|
||||
auto j = std::__uninitialized_default_n(i, n);
|
||||
VERIFY( j == (i + 4) );
|
||||
// i[0:3] are default-initialized so have indeterminate values.
|
||||
VERIFY( i[4] == 5 );
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -42,10 +42,15 @@ test02()
|
||||
int operator>(void*) { return value != 0; }
|
||||
};
|
||||
|
||||
int i[3];
|
||||
int i[5] = { 1, 2, 3, 4, 5 };
|
||||
Size n = {4};
|
||||
auto j = std::__uninitialized_default_n(i, n);
|
||||
VERIFY( j == (i + 4) );
|
||||
VERIFY( i[0] == 0 );
|
||||
VERIFY( i[1] == 0 );
|
||||
VERIFY( i[2] == 0 );
|
||||
VERIFY( i[3] == 0 );
|
||||
VERIFY( i[4] == 5 );
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
x
Reference in New Issue
Block a user