From 607474c1ea7c1e4fc4a5ac220236afb72dba8c21 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Mon, 1 Jul 2013 19:44:16 +0100 Subject: 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. --- source/pdf/pdf-write.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source/pdf') 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; } } -- cgit v1.2.3