summaryrefslogtreecommitdiff
path: root/pdf/pdf_stream.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2011-09-21 00:11:22 +0200
committerTor Andersson <tor.andersson@artifex.com>2011-09-21 00:11:22 +0200
commit69ed4a8f4dbfac7f2f1de925e34807e4fee3b27c (patch)
treeb7f82296a259d360ce90f0826e475321d630a222 /pdf/pdf_stream.c
parent99ba154018b7c4a2c47b4c7e721ffe6d9164f9f3 (diff)
downloadmupdf-69ed4a8f4dbfac7f2f1de925e34807e4fee3b27c.tar.xz
Don't thread ctx through safe fz_obj functions.
Diffstat (limited to 'pdf/pdf_stream.c')
-rw-r--r--pdf/pdf_stream.c75
1 files changed, 35 insertions, 40 deletions
diff --git a/pdf/pdf_stream.c b/pdf/pdf_stream.c
index 4fb9adce..ccf96da9 100644
--- a/pdf/pdf_stream.c
+++ b/pdf/pdf_stream.c
@@ -32,18 +32,18 @@ pdf_stream_has_crypt(fz_context *ctx, fz_obj *stm)
fz_obj *obj;
int i;
- filters = fz_dict_getsa(ctx, stm, "Filter", "F");
+ filters = fz_dict_getsa(stm, "Filter", "F");
if (filters)
{
- if (!strcmp(fz_to_name(ctx, filters), "Crypt"))
+ if (!strcmp(fz_to_name(filters), "Crypt"))
return 1;
- if (fz_is_array(ctx, filters))
+ if (fz_is_array(filters))
{
- int n = fz_array_len(ctx, filters);
+ int n = fz_array_len(filters);
for (i = 0; i < n; i++)
{
- obj = fz_array_get(ctx, filters, i);
- if (!strcmp(fz_to_name(ctx, obj), "Crypt"))
+ obj = fz_array_get(filters, i);
+ if (!strcmp(fz_to_name(obj), "Crypt"))
return 1;
}
}
@@ -61,7 +61,7 @@ build_filter(fz_stream *chain, pdf_xref * xref, fz_obj * f, fz_obj * p, int num,
char *s;
fz_context *ctx = chain->ctx;
- s = fz_to_name(ctx, f);
+ s = fz_to_name(f);
if (!strcmp(s, "ASCIIHexDecode") || !strcmp(s, "AHx"))
return fz_open_ahxd(chain);
@@ -80,23 +80,23 @@ build_filter(fz_stream *chain, pdf_xref * xref, fz_obj * f, fz_obj * p, int num,
else if (!strcmp(s, "FlateDecode") || !strcmp(s, "Fl"))
{
- fz_obj *obj = fz_dict_gets(ctx, p, "Predictor");
- if (fz_to_int(ctx, obj) > 1)
+ fz_obj *obj = fz_dict_gets(p, "Predictor");
+ if (fz_to_int(obj) > 1)
return fz_open_predict(fz_open_flated(chain), p);
return fz_open_flated(chain);
}
else if (!strcmp(s, "LZWDecode") || !strcmp(s, "LZW"))
{
- fz_obj *obj = fz_dict_gets(ctx, p, "Predictor");
- if (fz_to_int(ctx, obj) > 1)
+ fz_obj *obj = fz_dict_gets(p, "Predictor");
+ if (fz_to_int(obj) > 1)
return fz_open_predict(fz_open_lzwd(chain, p), p);
return fz_open_lzwd(chain, p);
}
else if (!strcmp(s, "JBIG2Decode"))
{
- fz_obj *obj = fz_dict_gets(ctx, p, "JBIG2Globals");
+ fz_obj *obj = fz_dict_gets(p, "JBIG2Globals");
if (obj)
{
fz_buffer *globals;
@@ -123,9 +123,9 @@ build_filter(fz_stream *chain, pdf_xref * xref, fz_obj * f, fz_obj * p, int num,
return chain;
}
- name = fz_dict_gets(ctx, p, "Name");
- if (fz_is_name(ctx, name))
- return pdf_open_crypt_with_filter(chain, xref->crypt, fz_to_name(ctx, name), num, gen);
+ name = fz_dict_gets(p, "Name");
+ if (fz_is_name(name))
+ return pdf_open_crypt_with_filter(chain, xref->crypt, fz_to_name(name), num, gen);
return chain;
}
@@ -145,13 +145,12 @@ build_filter_chain(fz_stream *chain, pdf_xref *xref, fz_obj *fs, fz_obj *ps, int
fz_obj *f;
fz_obj *p;
int i, n;
- fz_context *ctx = chain->ctx;
- n = fz_array_len(ctx, fs);
+ n = fz_array_len(fs);
for (i = 0; i < n; i++)
{
- f = fz_array_get(ctx, fs, i);
- p = fz_array_get(ctx, ps, i);
+ f = fz_array_get(fs, i);
+ p = fz_array_get(ps, i);
chain = build_filter(chain, xref, f, p, num, gen);
}
@@ -173,7 +172,7 @@ pdf_open_raw_filter(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int num, i
/* don't close chain when we close this filter */
fz_keep_stream(chain);
- len = fz_to_int(ctx, fz_dict_gets(ctx, stmobj, "Length"));
+ len = fz_to_int(fz_dict_gets(stmobj, "Length"));
chain = fz_open_null(chain, len);
hascrypt = pdf_stream_has_crypt(ctx, stmobj);
@@ -192,16 +191,15 @@ pdf_open_filter(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int num, int g
{
fz_obj *filters;
fz_obj *params;
- fz_context *ctx = chain->ctx;
- filters = fz_dict_getsa(ctx, stmobj, "Filter", "F");
- params = fz_dict_getsa(ctx, stmobj, "DecodeParms", "DP");
+ filters = fz_dict_getsa(stmobj, "Filter", "F");
+ params = fz_dict_getsa(stmobj, "DecodeParms", "DP");
chain = pdf_open_raw_filter(chain, xref, stmobj, num, gen);
- if (fz_is_name(ctx, filters))
+ if (fz_is_name(filters))
return build_filter(chain, xref, filters, params, num, gen);
- if (fz_array_len(ctx, filters) > 0)
+ if (fz_array_len(filters) > 0)
return build_filter_chain(chain, xref, filters, params, num, gen);
return chain;
@@ -216,17 +214,16 @@ pdf_open_inline_stream(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int len
{
fz_obj *filters;
fz_obj *params;
- fz_context *ctx = chain->ctx;
- filters = fz_dict_getsa(ctx, stmobj, "Filter", "F");
- params = fz_dict_getsa(ctx, stmobj, "DecodeParms", "DP");
+ filters = fz_dict_getsa(stmobj, "Filter", "F");
+ params = fz_dict_getsa(stmobj, "DecodeParms", "DP");
/* don't close chain when we close this filter */
fz_keep_stream(chain);
- if (fz_is_name(ctx, filters))
+ if (fz_is_name(filters))
return build_filter(chain, xref, filters, params, 0, 0);
- if (fz_array_len(ctx, filters) > 0)
+ if (fz_array_len(filters) > 0)
return build_filter_chain(chain, xref, filters, params, 0, 0);
return fz_open_null(chain, length);
@@ -313,15 +310,14 @@ pdf_load_raw_stream(fz_buffer **bufp, pdf_xref *xref, int num, int gen)
fz_stream *stm;
fz_obj *dict;
int len;
- fz_context *ctx = xref->ctx;
error = pdf_load_object(&dict, xref, num, gen);
if (error)
return fz_error_note(error, "cannot load stream dictionary (%d %d R)", num, gen);
- len = fz_to_int(ctx, fz_dict_gets(ctx, dict, "Length"));
+ len = fz_to_int(fz_dict_gets(dict, "Length"));
- fz_drop_obj(ctx, dict);
+ fz_drop_obj(dict);
error = pdf_open_raw_stream(&stm, xref, num, gen);
if (error)
@@ -364,7 +360,6 @@ pdf_load_stream(fz_buffer **bufp, pdf_xref *xref, int num, int gen)
fz_stream *stm;
fz_obj *dict, *obj;
int i, len, n;
- fz_context *ctx = xref->ctx;
error = pdf_open_stream(&stm, xref, num, gen);
if (error)
@@ -374,14 +369,14 @@ pdf_load_stream(fz_buffer **bufp, pdf_xref *xref, int num, int gen)
if (error)
return fz_error_note(error, "cannot load stream dictionary (%d %d R)", num, gen);
- len = fz_to_int(ctx, fz_dict_gets(ctx, dict, "Length"));
- obj = fz_dict_gets(ctx, dict, "Filter");
- len = pdf_guess_filter_length(len, fz_to_name(ctx, obj));
- n = fz_array_len(ctx, obj);
+ len = fz_to_int(fz_dict_gets(dict, "Length"));
+ obj = fz_dict_gets(dict, "Filter");
+ len = pdf_guess_filter_length(len, fz_to_name(obj));
+ n = fz_array_len(obj);
for (i = 0; i < n; i++)
- len = pdf_guess_filter_length(len, fz_to_name(ctx, fz_array_get(ctx, obj, i)));
+ len = pdf_guess_filter_length(len, fz_to_name(fz_array_get(obj, i)));
- fz_drop_obj(ctx, dict);
+ fz_drop_obj(dict);
error = fz_read_all(bufp, stm, len);
if (error)