diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index 71a1efe..435b30f 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -615,9 +615,12 @@ int PDFDoc::savePageAs(GooString *name, int pageNo) { FILE *f; OutStream *outStr; - XRef *yRef, *countRef; + XRef *yRef, *countRef, *savedXRef; int rootNum = getXRef()->getNumObjects() + 1; + savedXRef = xref; + xref = xref->copy(); + // Make sure that special flags are set, because we are going to read // all objects, including Unencrypted ones. xref->scanSpecialFlags(); @@ -775,6 +778,9 @@ int PDFDoc::savePageAs(GooString *name, int pageNo) delete countRef; delete outStr; + delete xref; + xref = savedXRef; + return errNone; }