summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fxcodec/codec/fx_codec_tiff.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/core/fxcodec/codec/fx_codec_tiff.cpp b/core/fxcodec/codec/fx_codec_tiff.cpp
index cf38d71b37..7818a34ec6 100644
--- a/core/fxcodec/codec/fx_codec_tiff.cpp
+++ b/core/fxcodec/codec/fx_codec_tiff.cpp
@@ -100,10 +100,14 @@ tsize_t tiff_read(thandle_t context, tdata_t buf, tsize_t length) {
if (!increment.IsValid())
return 0;
- if (!pTiffContext->io_in()->ReadBlock(buf, pTiffContext->offset(), length))
+ FX_FILESIZE offset = pTiffContext->offset();
+ if (!pTiffContext->io_in()->ReadBlock(buf, offset, length))
return 0;
pTiffContext->set_offset(increment.ValueOrDie());
+ if (offset + length > pTiffContext->io_in()->GetSize())
+ return pTiffContext->io_in()->GetSize() - offset;
+
return length;
}