From 6cc1ecc4d35a31b845e361cce2707ad4cb8041c0 Mon Sep 17 00:00:00 2001 From: zeniko Date: Sat, 18 May 2013 23:54:28 +0200 Subject: Avoid assert, and pull in changes. Fix from zeniko. --- fitz/image_jpx.c | 6 ++++-- 1 file 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) { -- cgit v1.2.3