summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-write.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2013-07-01 19:44:16 +0100
committerRobin Watts <robin.watts@artifex.com>2013-07-02 12:16:21 +0100
commit607474c1ea7c1e4fc4a5ac220236afb72dba8c21 (patch)
tree2439580b41280133d2fdf6df1318697775342b49 /source/pdf/pdf-write.c
parent10ffbc1df88eb370a73aca6b07cc797db2690b97 (diff)
downloadmupdf-607474c1ea7c1e4fc4a5ac220236afb72dba8c21.tar.xz
Fix "mutool clean -ggg" operation.
When moving an object from one xref to a new xref, ensure firstly that we only drop each object once (by setting it to NULL) and secondly that it has the correct parent pointer.
Diffstat (limited to 'source/pdf/pdf-write.c')
-rw-r--r--source/pdf/pdf-write.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c
index 00718848..27fe6d6c 100644
--- a/source/pdf/pdf-write.c
+++ b/source/pdf/pdf-write.c
@@ -793,14 +793,23 @@ static void renumberobjs(pdf_document *doc, pdf_write_options *opts)
{
if (opts->use_list[num])
{
+ pdf_xref_entry *e;
if (newlen < opts->renumber_map[num])
newlen = opts->renumber_map[num];
- newxref[opts->renumber_map[num]] = *pdf_get_xref_entry(doc, num);
+ e = pdf_get_xref_entry(doc, num);
+ newxref[opts->renumber_map[num]] = *e;
+ if (e->obj)
+ {
+ pdf_set_objects_parent_num(e->obj, opts->renumber_map[num]);
+ e->obj = NULL;
+ }
new_use_list[opts->renumber_map[num]] = opts->use_list[num];
}
else
{
- pdf_drop_obj(pdf_get_xref_entry(doc, num)->obj);
+ pdf_xref_entry *e = pdf_get_xref_entry(doc, num);
+ pdf_drop_obj(e->obj);
+ e->obj = NULL;
}
}