Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: testing/libfuzzer/pdf_codec_fax_fuzzer.cc

Issue 2357173005: Clean up fx_codec_fax.cpp. (Closed)
Patch Set: typo Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fxcodec/codec/fx_codec_fax.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The PDFium Authors. All rights reserved. 1 // Copyright 2016 The PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <cstdint> 5 #include <cstdint>
6 #include <memory> 6 #include <memory>
7 7
8 #include "core/fxcodec/codec/ccodec_faxmodule.h" 8 #include "core/fxcodec/codec/ccodec_faxmodule.h"
9 #include "core/fxcodec/codec/ccodec_scanlinedecoder.h" 9 #include "core/fxcodec/codec/ccodec_scanlinedecoder.h"
10 10
11 static int GetInteger(const uint8_t* data) { 11 static int GetInteger(const uint8_t* data) {
12 return data[0] | data[1] << 8 | data[2] << 16 | data[3] << 24; 12 return data[0] | data[1] << 8 | data[2] << 16 | data[3] << 24;
13 } 13 }
14 14
15 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 15 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
16 const int kParameterSize = 21; 16 const int kParameterSize = 21;
17 if (size < kParameterSize) 17 if (size < kParameterSize)
18 return 0; 18 return 0;
19 19
20 int width = GetInteger(data); 20 int width = GetInteger(data);
21 int height = GetInteger(data + 4); 21 int height = GetInteger(data + 4);
22 int K = GetInteger(data + 8); 22 int K = GetInteger(data + 8);
23 int Columns = GetInteger(data + 12); 23 int Columns = GetInteger(data + 12);
24 int Rows = GetInteger(data + 16); 24 int Rows = GetInteger(data + 16);
25 FX_BOOL EndOfLine = (data[20] & 0x01) == 0; 25 bool EndOfLine = !(data[20] & 0x01);
26 FX_BOOL ByteAlign = (data[20] & 0x02) == 0; 26 bool ByteAlign = !(data[20] & 0x02);
27 FX_BOOL BlackIs1 = (data[20] & 0x04) == 0; 27 bool BlackIs1 = !(data[20] & 0x04);
28 data += kParameterSize; 28 data += kParameterSize;
29 size -= kParameterSize; 29 size -= kParameterSize;
30 30
31 CCodec_FaxModule fax_module; 31 CCodec_FaxModule fax_module;
32 std::unique_ptr<CCodec_ScanlineDecoder> decoder; 32 std::unique_ptr<CCodec_ScanlineDecoder> decoder(
33 decoder.reset(fax_module.CreateDecoder(data, size, width, height, K, 33 fax_module.CreateDecoder(data, size, width, height, K, EndOfLine,
34 EndOfLine, ByteAlign, BlackIs1, 34 ByteAlign, BlackIs1, Columns, Rows));
35 Columns, Rows));
36 35
37 if (decoder) { 36 if (decoder) {
38 int line = 0; 37 int line = 0;
39 while (decoder->GetScanline(line)) 38 while (decoder->GetScanline(line))
40 line++; 39 line++;
41 } 40 }
42 41
43 return 0; 42 return 0;
44 } 43 }
OLDNEW
« no previous file with comments | « core/fxcodec/codec/fx_codec_fax.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698