From 59bd2f5bfc486b107c4bd689bd65ea7d23e2fad0 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 6 Oct 2004 11:36:25 +0200 Subject: hashtable and object store memory bugs --- test/pdfdebug.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'test/pdfdebug.c') diff --git a/test/pdfdebug.c b/test/pdfdebug.c index ddc10dff..1009849f 100644 --- a/test/pdfdebug.c +++ b/test/pdfdebug.c @@ -5,10 +5,11 @@ static char *password = ""; static int dodecode = 0; static int dorepair = 0; static int doprintxref = 0; +static int dosave = 0; void usage() { - fprintf(stderr, "usage: pdfdebug [-drx] [-u password] file.pdf [oid ...]\n"); + fprintf(stderr, "usage: pdfdebug [-drxs] [-u password] file.pdf [oid ...]\n"); exit(1); } @@ -43,9 +44,13 @@ void printsafe(unsigned char *buf, int n) void decodestream(pdf_xref *xref, fz_obj *stream, int oid, int gid, int ofs) { + FILE *copy; fz_error *error; unsigned char buf[512]; + if (dosave) + copy = fopen("/tmp/dump.stm", "wb"); + safecol = 0; error = pdf_openstream0(xref, stream, oid, gid, ofs); @@ -59,8 +64,14 @@ void decodestream(pdf_xref *xref, fz_obj *stream, int oid, int gid, int ofs) if (n < 0) fz_abort(fz_ferror(xref->file)); printsafe(buf, n); + + if (dosave) + fwrite(buf, 1, n, copy); } + if (dosave) + fclose(copy); + pdf_closestream(xref); } @@ -133,10 +144,13 @@ int main(int argc, char **argv) pdf_xref *xref; int c; - while ((c = getopt(argc, argv, "drxopu:")) != -1) + while ((c = getopt(argc, argv, "drxsopu:")) != -1) { switch (c) { + case 's': + dodecode ++; + dosave ++; case 'd': dodecode ++; break; -- cgit v1.2.3