diff options
-rw-r--r-- | include/mupdf/fitz/output.h | 3 | ||||
-rw-r--r-- | source/fitz/bitmap.c | 6 | ||||
-rw-r--r-- | source/fitz/output.c | 31 | ||||
-rw-r--r-- | source/fitz/pixmap.c | 6 |
4 files changed, 15 insertions, 31 deletions
diff --git a/include/mupdf/fitz/output.h b/include/mupdf/fitz/output.h index fbb769ae..efae50f5 100644 --- a/include/mupdf/fitz/output.h +++ b/include/mupdf/fitz/output.h @@ -62,7 +62,8 @@ void fz_drop_output(fz_context *, fz_output *); static inline void fz_write(fz_context *ctx, fz_output *out, const void *data, int size) { - out->write(ctx, out->opaque, data, size); + if (out) + out->write(ctx, out->opaque, data, size); } /* diff --git a/source/fitz/bitmap.c b/source/fitz/bitmap.c index 540d54cf..b610737a 100644 --- a/source/fitz/bitmap.c +++ b/source/fitz/bitmap.c @@ -342,6 +342,9 @@ fz_write_pbm_band(fz_context *ctx, fz_output *out, fz_bitmap *bitmap) if (bitmap->n != 1) fz_throw(ctx, FZ_ERROR_GENERIC, "too many color components in bitmap"); + if (!out) + return; + p = bitmap->samples; h = bitmap->h; bytestride = (bitmap->w + 7) >> 3; @@ -361,6 +364,9 @@ fz_write_pkm_band(fz_context *ctx, fz_output *out, fz_bitmap *bitmap) if (bitmap->n != 4) fz_throw(ctx, FZ_ERROR_GENERIC, "wrong number of color components in bitmap"); + if (!out) + return; + p = bitmap->samples; h = bitmap->h; w = bitmap->w; diff --git a/source/fitz/output.c b/source/fitz/output.c index 1904ee85..9ea2d169 100644 --- a/source/fitz/output.c +++ b/source/fitz/output.c @@ -62,35 +62,6 @@ fz_new_output_with_file_ptr(fz_context *ctx, FILE *file, int close) return out; } -static void -null_write(fz_context *ctx, void *opaque, const void *buffer, int count) -{ - return; -} - -static void -null_seek(fz_context *ctx, void *opaque, fz_off_t off, int whence) -{ -} - -static fz_off_t -null_tell(fz_context *ctx, void *opaque) -{ - return 0; -} - -static fz_output * -null_filename(fz_context *ctx) -{ - fz_output *out = fz_malloc_struct(ctx, fz_output); - out->opaque = NULL; - out->write = null_write; - out->seek = null_seek; - out->tell = null_tell; - out->close = NULL; - return out; -} - fz_output * fz_new_output_with_path(fz_context *ctx, const char *filename, int append) { @@ -98,7 +69,7 @@ fz_new_output_with_path(fz_context *ctx, const char *filename, int append) FILE *file; if (!strcmp(filename, "/dev/null") || !fz_strcasecmp(filename, "nul:")) - return null_filename(ctx); + return NULL; file = fz_fopen(filename, append ? "ab" : "wb"); if (!file) diff --git a/source/fitz/pixmap.c b/source/fitz/pixmap.c index 2b72cd00..018b5907 100644 --- a/source/fitz/pixmap.c +++ b/source/fitz/pixmap.c @@ -587,6 +587,9 @@ fz_write_pnm_band(fz_context *ctx, fz_output *out, int w, int h, int n, int band int start = band * bandheight; int end = start + bandheight; + if (!out) + return; + if (end > h) end = h; end -= start; @@ -699,6 +702,9 @@ fz_write_pam_band(fz_context *ctx, fz_output *out, int w, int h, int n, int band if (!savealpha && dn > 1) dn--; + if (!out) + return; + if (end > h) end = h; end -= start; |