Skip to content

Commit 5edcd42

Browse files
rouaultjonathanmetzman
authored andcommitted
libjpeg-turbo: enable i386 architecture and improve fuzzer regarding msan (#2680)
1 parent 8776ec2 commit 5edcd42

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

projects/libjpeg-turbo/libjpeg_turbo_fuzzer.cc

+19-1
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,28 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
3939
return 0;
4040
}
4141

42-
std::unique_ptr<unsigned char[]> buf(new unsigned char[width * height * 3]);
42+
const int buffer_size = width * height * 3;
43+
std::unique_ptr<unsigned char[]> buf(new unsigned char[buffer_size]);
4344
tjDecompress2(
4445
jpegDecompressor, data, size, buf.get(), width, 0, height, TJPF_RGB, 0);
4546

47+
// For memory sanitizer, test each output byte
48+
const unsigned char* raw_buf = buf.get();
49+
int count = 0;
50+
for( int i = 0; i < buffer_size; i++ )
51+
{
52+
if (raw_buf[i])
53+
{
54+
count ++;
55+
}
56+
}
57+
if (count == buffer_size)
58+
{
59+
// Do something with side effect, so that all the above tests don't
60+
// get removed by the optimizer.
61+
free(malloc(1));
62+
}
63+
4664
tjDestroy(jpegDecompressor);
4765

4866
return 0;

projects/libjpeg-turbo/project.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ sanitizers:
33
- address
44
- memory
55
- undefined
6+
architectures:
7+
- x86_64
8+
- i386

0 commit comments

Comments
 (0)