diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2011-04-09 23:15:17 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2011-04-09 23:15:17 +0200 |
commit | 4a05689ac239535c3441f8d43d21c1373bc0194a (patch) | |
tree | 4d5ef120cc0f0f8e7f91ff0912adee802f60c9f2 | |
parent | 63848329d1ee61e30a557a31a3b2d811a13ed421 (diff) | |
download | mupdf-4a05689ac239535c3441f8d43d21c1373bc0194a.tar.xz |
Throw an error if none of the content stream parts could be loaded.
-rw-r--r-- | fitz/fitz.h | 18 | ||||
-rw-r--r-- | pdf/pdf_page.c | 8 |
2 files changed, 15 insertions, 11 deletions
diff --git a/fitz/fitz.h b/fitz/fitz.h index 491db28b..7de81c42 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -15,11 +15,16 @@ #include <assert.h> #include <errno.h> #include <limits.h> /* INT_MAX & co */ -#include <float.h> /* FLT_EPSILON */ -#include <fcntl.h> /* O_RDONLY & co */ +#include <float.h> /* FLT_EPSILON */ +#include <fcntl.h> /* O_RDONLY & co */ #define nelem(x) (sizeof(x)/sizeof((x)[0])) +#define ABS(x) ( (x) < 0 ? -(x) : (x) ) +#define MIN(a,b) ( (a) < (b) ? (a) : (b) ) +#define MAX(a,b) ( (a) > (b) ? (a) : (b) ) +#define CLAMP(x,a,b) ( (x) > (b) ? (b) : ( (x) < (a) ? (a) : (x) ) ) + /* * Some differences in libc can be smoothed over */ @@ -110,6 +115,8 @@ int gettimeofday(struct timeval *tv, struct timezone *tz); typedef int fz_error; +#define fz_okay ((fz_error)0) + void fz_warn(char *fmt, ...) __printflike(1, 2); void fz_flush_warnings(void); @@ -121,8 +128,6 @@ fz_error fz_throw_impx(char *fmt, ...) __printflike(1, 2); fz_error fz_rethrow_impx(fz_error cause, char *fmt, ...) __printflike(2, 3); void fz_catch_impx(fz_error cause, char *fmt, ...) __printflike(2, 3); -#define fz_okay ((fz_error)0) - /* extract the last error stack trace */ int fz_get_error_count(void); char *fz_get_error_line(int n); @@ -131,11 +136,6 @@ char *fz_get_error_line(int n); * Basic runtime and utility functions */ -#define ABS(x) ( (x) < 0 ? -(x) : (x) ) -#define MIN(a,b) ( (a) < (b) ? (a) : (b) ) -#define MAX(a,b) ( (a) > (b) ? (a) : (b) ) -#define CLAMP(x,a,b) ( (x) > (b) ? (b) : ( (x) < (a) ? (a) : (x) ) ) - /* memory allocation */ void *fz_malloc(int size); void *fz_calloc(int count, int size); diff --git a/pdf/pdf_page.c b/pdf/pdf_page.c index bf9bf411..7837c4cf 100644 --- a/pdf/pdf_page.c +++ b/pdf/pdf_page.c @@ -209,8 +209,6 @@ pdf_load_page_contents_array(fz_buffer **bigbufp, pdf_xref *xref, fz_obj *list) fz_buffer *one; int i, n; - /* TODO: openstream, read, close into big buffer at once */ - big = fz_new_buffer(32 * 1024); n = fz_array_len(list); @@ -233,6 +231,12 @@ pdf_load_page_contents_array(fz_buffer **bigbufp, pdf_xref *xref, fz_obj *list) fz_drop_buffer(one); } + if (n > 0 && big->len == 0) + { + fz_drop_buffer(big); + return fz_throw("cannot load content stream"); + } + *bigbufp = big; return fz_okay; } |