OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "core/fxcodec/codec/codec_int.h" | 9 #include "core/fxcodec/codec/codec_int.h" |
10 #include "core/fxcodec/fx_codec.h" | 10 #include "core/fxcodec/fx_codec.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 namespace { | 91 namespace { |
92 | 92 |
93 tsize_t tiff_read(thandle_t context, tdata_t buf, tsize_t length) { | 93 tsize_t tiff_read(thandle_t context, tdata_t buf, tsize_t length) { |
94 CCodec_TiffContext* pTiffContext = | 94 CCodec_TiffContext* pTiffContext = |
95 reinterpret_cast<CCodec_TiffContext*>(context); | 95 reinterpret_cast<CCodec_TiffContext*>(context); |
96 FX_SAFE_UINT32 increment = pTiffContext->offset(); | 96 FX_SAFE_UINT32 increment = pTiffContext->offset(); |
97 increment += length; | 97 increment += length; |
98 if (!increment.IsValid()) | 98 if (!increment.IsValid()) |
99 return 0; | 99 return 0; |
100 | 100 |
101 if (!pTiffContext->io_in()->ReadBlock(buf, pTiffContext->offset(), length)) | 101 size_t readSize = |
| 102 pTiffContext->io_in()->ReadBlock(buf, pTiffContext->offset(), length); |
| 103 if (readSize != static_cast<size_t>(length) && |
| 104 !pTiffContext->io_in()->IsEOF()) |
102 return 0; | 105 return 0; |
103 | 106 |
104 pTiffContext->set_offset(increment.ValueOrDie()); | 107 pTiffContext->set_offset(increment.ValueOrDie() - length + readSize); |
105 return length; | 108 return readSize; |
106 } | 109 } |
107 | 110 |
108 tsize_t tiff_write(thandle_t context, tdata_t buf, tsize_t length) { | 111 tsize_t tiff_write(thandle_t context, tdata_t buf, tsize_t length) { |
109 ASSERT(false); | 112 ASSERT(false); |
110 return 0; | 113 return 0; |
111 } | 114 } |
112 | 115 |
113 toff_t tiff_seek(thandle_t context, toff_t offset, int whence) { | 116 toff_t tiff_seek(thandle_t context, toff_t offset, int whence) { |
114 CCodec_TiffContext* pTiffContext = | 117 CCodec_TiffContext* pTiffContext = |
115 reinterpret_cast<CCodec_TiffContext*>(context); | 118 reinterpret_cast<CCodec_TiffContext*>(context); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 } | 481 } |
479 | 482 |
480 bool CCodec_TiffModule::Decode(CCodec_TiffContext* ctx, | 483 bool CCodec_TiffModule::Decode(CCodec_TiffContext* ctx, |
481 class CFX_DIBitmap* pDIBitmap) { | 484 class CFX_DIBitmap* pDIBitmap) { |
482 return ctx->Decode(pDIBitmap); | 485 return ctx->Decode(pDIBitmap); |
483 } | 486 } |
484 | 487 |
485 void CCodec_TiffModule::DestroyDecoder(CCodec_TiffContext* ctx) { | 488 void CCodec_TiffModule::DestroyDecoder(CCodec_TiffContext* ctx) { |
486 delete ctx; | 489 delete ctx; |
487 } | 490 } |
OLD | NEW |