summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fitz/image_jpx.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fitz/image_jpx.c b/fitz/image_jpx.c
index f680b50c..f8e6d8c0 100644
--- a/fitz/image_jpx.c
+++ b/fitz/image_jpx.c
@@ -35,6 +35,8 @@ OPJ_SIZE_T stream_read(void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_dat
len = sb->size - sb->pos;
if (len < 0)
len = 0;
+ if (len == 0)
+ return (OPJ_SIZE_T)-1; /* End of file! */
if (len > p_nb_bytes)
len = p_nb_bytes;
memcpy(p_buffer, sb->data + sb->pos, len);