diff options
Diffstat (limited to 'fitz/stm_read.c')
-rw-r--r-- | fitz/stm_read.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/fitz/stm_read.c b/fitz/stm_read.c index ff97340f..5622a24f 100644 --- a/fitz/stm_read.c +++ b/fitz/stm_read.c @@ -23,7 +23,7 @@ fz_read(fz_stream *stm, unsigned char *buf, int len) if (n < 0) { stm->error = 1; - return fz_rethrow(n, "read error"); + return fz_error_note(n, "read error"); } else if (n == 0) { @@ -50,7 +50,7 @@ fz_read(fz_stream *stm, unsigned char *buf, int len) if (n < 0) { stm->error = 1; - return fz_rethrow(n, "read error"); + return fz_error_note(n, "read error"); } else if (n == 0) { @@ -80,7 +80,7 @@ fz_fill_buffer(fz_stream *stm) if (n < 0) { stm->error = 1; - fz_catch(n, "read error; treating as end of file"); + fz_error_handle(n, "read error; treating as end of file"); } else if (n == 0) { @@ -94,33 +94,34 @@ fz_fill_buffer(fz_stream *stm) } } -fz_error -fz_read_all(fz_buffer **bufp, fz_stream *stm, int initial) +fz_buffer * +fz_read_all(fz_stream *stm, int initial) { fz_buffer *buf; int n; + fz_context *ctx = stm->ctx; if (initial < 1024) initial = 1024; - buf = fz_new_buffer(initial); + buf = fz_new_buffer(ctx, initial); while (1) { if (buf->len == buf->cap) - fz_grow_buffer(buf); + fz_grow_buffer(ctx, buf); if (buf->len / 200 > initial) { - fz_drop_buffer(buf); - return fz_throw("compression bomb detected"); + fz_drop_buffer(ctx, buf); + fz_throw(ctx, "compression bomb detected"); } n = fz_read(stm, buf->data + buf->len, buf->cap - buf->len); if (n < 0) { - fz_drop_buffer(buf); - return fz_rethrow(n, "read error"); + fz_drop_buffer(ctx, buf); + fz_throw(ctx, "read error"); } if (n == 0) break; @@ -128,8 +129,7 @@ fz_read_all(fz_buffer **bufp, fz_stream *stm, int initial) buf->len += n; } - *bufp = buf; - return fz_okay; + return buf; } void @@ -191,11 +191,11 @@ fz_seek(fz_stream *stm, int offset, int whence) if (whence == 0) offset -= fz_tell(stm); if (offset < 0) - fz_warn("cannot seek backwards"); + fz_warn(stm->ctx, "cannot seek backwards"); /* dog slow, but rare enough */ while (offset-- > 0) fz_read_byte(stm); } else - fz_warn("cannot seek"); + fz_warn(stm->ctx, "cannot seek"); } |