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

Unified Diff: core/src/fxcodec/codec/fx_codec_jpx_opj.cpp

Issue 990683002: Fix a bug that JPX images can't be shown (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
index c4a0f88201a81db97599ac9aea9b1d7385585cdd..164fd3e7159d4ee6c78c949bd38c0cdede3f6619 100644
--- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
@@ -52,9 +52,13 @@ static OPJ_SIZE_T opj_write_from_memory (void * p_buffer, OPJ_SIZE_T p_nb_bytes,
static OPJ_OFF_T opj_skip_from_memory (OPJ_OFF_T p_nb_bytes, void* p_user_data)
{
DecodeData* srcData = static_cast<DecodeData*>(p_user_data);
- if (srcData == NULL || srcData->src_size == 0 || srcData->src_data == NULL || srcData->offset >= srcData->src_size) {
+ if (srcData == NULL || srcData->src_size == 0 || srcData->src_data == NULL) {
return -1;
}
+ if (srcData->offset >= srcData->src_size) {
+ srcData->offset = srcData->src_size;
+ return p_nb_bytes;
+ }
OPJ_SIZE_T bufferLength = srcData->src_size - srcData->offset;
OPJ_SIZE_T skipLength = p_nb_bytes < bufferLength ? p_nb_bytes : bufferLength;
srcData->offset += skipLength;
@@ -63,9 +67,12 @@ static OPJ_OFF_T opj_skip_from_memory (OPJ_OFF_T p_nb_bytes, void* p_user_data)
static OPJ_BOOL opj_seek_from_memory (OPJ_OFF_T p_nb_bytes, void* p_user_data)
{
DecodeData* srcData = static_cast<DecodeData*>(p_user_data);
- if (srcData == NULL || srcData->src_size == 0 || srcData->src_data == NULL || srcData->offset >= srcData->src_size) {
+ if (srcData == NULL || srcData->src_size == 0 || srcData->src_data == NULL) {
return OPJ_FALSE;
}
+ if (srcData->offset >= srcData->src_size) {
+ return OPJ_TRUE;
+ }
if (p_nb_bytes >= srcData->src_size) {
return OPJ_FALSE;
}
@@ -629,7 +636,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, int src_size)
image = NULL;
return FALSE;
}
- if (!(opj_decode(l_codec, l_stream, image) && opj_end_decompress(l_codec, l_stream))) {
+ if (!(opj_decode(l_codec, l_stream, image) && opj_end_decompress(l_codec, l_stream))) {
opj_image_destroy(image);
image = NULL;
return FALSE;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698