mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-03 04:50:29 +00:00
Tests: Use ByteBuffer::create_zeroed in TestDeflate instead of memset
The round trip compress test wants the first half of the byte buffer to be filled with random data, and the second half to be all zeroes. The strategy of using memset on ByteBuffer::offset_pointer confuses __builtin_memset_chk when building with -fsanitize=undefined. It thinks that the buffer is using inline capacity when we can prove to ourselves pretty easily that it's not. To avoid this, just create the buffer zeroed to start, and then fill the first half with the random data.
This commit is contained in:
parent
0e4431af33
commit
a223ef3c4f
Notes:
sideshowbarker
2024-07-18 17:19:15 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/a223ef3c4fa Pull-request: https://github.com/SerenityOS/serenity/pull/7434 Reviewed-by: https://github.com/awesomekling
1 changed files with 2 additions and 3 deletions
|
@ -124,9 +124,8 @@ TEST_CASE(deflate_round_trip_store)
|
|||
|
||||
TEST_CASE(deflate_round_trip_compress)
|
||||
{
|
||||
auto original = ByteBuffer::create_uninitialized(2048);
|
||||
fill_with_random(original.data(), 1024);
|
||||
memset(original.offset_pointer(1024), 0, 1024); // we fill the second half with 0s to make sure we test back references as well
|
||||
auto original = ByteBuffer::create_zeroed(2048);
|
||||
fill_with_random(original.data(), 1024); // we pre-filled the second half with 0s to make sure we test back references as well
|
||||
// Since the different levels just change how much time is spent looking for better matches, just use fast here to reduce test time
|
||||
auto compressed = Compress::DeflateCompressor::compress_all(original, Compress::DeflateCompressor::CompressionLevel::FAST);
|
||||
EXPECT(compressed.has_value());
|
||||
|
|
Loading…
Reference in a new issue