summaryrefslogtreecommitdiff
path: root/fitz/stm_open.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2011-12-15 19:49:16 +0000
committerRobin Watts <robin.watts@artifex.com>2011-12-15 19:49:16 +0000
commite6118ac1b13cc49f637861fccbc32a10c4ea1ea7 (patch)
tree4ccb1fb5adf96d7794872502ee975825f250054a /fitz/stm_open.c
parent3031a2480fe775df825de6674495d01ae2607d93 (diff)
downloadmupdf-e6118ac1b13cc49f637861fccbc32a10c4ea1ea7.tar.xz
Various Memsqueezing fixes.
Fixes for leaks (and SEGVs, division by zeros etc) seen when Memsqueezing.
Diffstat (limited to 'fitz/stm_open.c')
-rw-r--r--fitz/stm_open.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/fitz/stm_open.c b/fitz/stm_open.c
index eade9788..733b4c6a 100644
--- a/fitz/stm_open.c
+++ b/fitz/stm_open.c
@@ -89,7 +89,15 @@ fz_open_fd(fz_context *ctx, int fd)
state = fz_malloc(ctx, sizeof(int));
*state = fd;
- stm = fz_new_stream(ctx, state, read_file, close_file);
+ fz_try(ctx)
+ {
+ stm = fz_new_stream(ctx, state, read_file, close_file);
+ }
+ fz_catch(ctx)
+ {
+ fz_free(ctx, state);
+ fz_rethrow(ctx);
+ }
stm->seek = seek_file;
return stm;