OLD | NEW |
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 #ifndef TESTING_LIBFUZZER_XFA_CODEC_FUZZER_H_ | 5 #ifndef TESTING_LIBFUZZER_XFA_CODEC_FUZZER_H_ |
6 #define TESTING_LIBFUZZER_XFA_CODEC_FUZZER_H_ | 6 #define TESTING_LIBFUZZER_XFA_CODEC_FUZZER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "core/fxcodec/codec/ccodec_progressivedecoder.h" | 10 #include "core/fxcodec/codec/ccodec_progressivedecoder.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 status = decoder->StartDecode(bitmap.get(), 0, 0, bitmap->GetWidth(), | 35 status = decoder->StartDecode(bitmap.get(), 0, 0, bitmap->GetWidth(), |
36 bitmap->GetHeight()); | 36 bitmap->GetHeight()); |
37 while (status == FXCODEC_STATUS_DECODE_TOBECONTINUE) | 37 while (status == FXCODEC_STATUS_DECODE_TOBECONTINUE) |
38 status = decoder->ContinueDecode(); | 38 status = decoder->ContinueDecode(); |
39 | 39 |
40 return 0; | 40 return 0; |
41 } | 41 } |
42 | 42 |
43 private: | 43 private: |
44 class Reader : public IFX_FileRead { | 44 class Reader : public IFX_SeekableReadStream { |
45 public: | 45 public: |
46 Reader(const uint8_t* data, size_t size) : m_data(data), m_size(size) {} | 46 Reader(const uint8_t* data, size_t size) : m_data(data), m_size(size) {} |
47 ~Reader() {} | 47 ~Reader() {} |
48 | 48 |
49 void Release() override {} | 49 void Release() override {} |
50 | 50 |
51 FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { | 51 FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { |
52 if (offset < 0 || offset >= m_size) | 52 if (offset < 0 || offset >= m_size) |
53 return FALSE; | 53 return FALSE; |
54 if (offset + size > m_size) | 54 if (offset + size > m_size) |
55 size = m_size - offset; | 55 size = m_size - offset; |
56 if (size == 0) | 56 if (size == 0) |
57 return FALSE; | 57 return FALSE; |
58 | 58 |
59 memcpy(buffer, m_data + offset, size); | 59 memcpy(buffer, m_data + offset, size); |
60 return TRUE; | 60 return TRUE; |
61 } | 61 } |
62 | 62 |
63 FX_FILESIZE GetSize() override { return static_cast<FX_FILESIZE>(m_size); } | 63 FX_FILESIZE GetSize() override { return static_cast<FX_FILESIZE>(m_size); } |
64 | 64 |
65 private: | 65 private: |
66 const uint8_t* const m_data; | 66 const uint8_t* const m_data; |
67 size_t m_size; | 67 size_t m_size; |
68 }; | 68 }; |
69 }; | 69 }; |
70 | 70 |
71 #endif // TESTING_LIBFUZZER_XFA_CODEC_FUZZER_H_ | 71 #endif // TESTING_LIBFUZZER_XFA_CODEC_FUZZER_H_ |
OLD | NEW |