summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeniko <zeniko@gmail.com>2013-05-18 23:54:28 +0200
committerRobin Watts <robin.watts@artifex.com>2013-05-24 18:13:19 +0100
commit6cc1ecc4d35a31b845e361cce2707ad4cb8041c0 (patch)
tree079ee0a473243276a6a6cfc080fc980a2a8edcf6
parentb306a1bdd8622afd226946879046a360021026df (diff)
downloadmupdf-6cc1ecc4d35a31b845e361cce2707ad4cb8041c0.tar.xz
Avoid assert, and pull in changes.
Fix from zeniko.
-rw-r--r--fitz/image_jpx.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fitz/image_jpx.c b/fitz/image_jpx.c
index 1c35c5fd..1006cfdb 100644
--- a/fitz/image_jpx.c
+++ b/fitz/image_jpx.c
@@ -44,7 +44,7 @@ OPJ_SIZE_T stream_read(void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_dat
len = 0;
if (len == 0)
return (OPJ_SIZE_T)-1; /* End of file! */
- if (len > p_nb_bytes)
+ if ((OPJ_SIZE_T)len > p_nb_bytes)
len = p_nb_bytes;
memcpy(p_buffer, sb->data + sb->pos, len);
sb->pos += len;
@@ -118,6 +118,8 @@ fz_load_jpx(fz_context *ctx, unsigned char *data, int size, fz_colorspace *defcs
opj_stream_set_skip_function(stream, stream_skip);
opj_stream_set_seek_function(stream, stream_seek);
opj_stream_set_user_data(stream, &sb);
+ /* Set the length to avoid an assert */
+ opj_stream_set_user_data_length(stream, size);
if (!opj_read_header(stream, codec, &jpx))
{
@@ -141,7 +143,7 @@ fz_load_jpx(fz_context *ctx, unsigned char *data, int size, fz_colorspace *defcs
if (!jpx)
fz_throw(ctx, "opj_decode failed");
- for (k = 1; k < jpx->numcomps; k++)
+ for (k = 1; k < (int)jpx->numcomps; k++)
{
if (jpx->comps[k].w != jpx->comps[0].w)
{