diff --git a/utils/pdfseparate.cc b/utils/pdfseparate.cc index bc98c7d..297098e 100644 --- a/utils/pdfseparate.cc +++ b/utils/pdfseparate.cc @@ -124,12 +124,15 @@ bool extractPages (const char *srcFileName, const char *destFileName) { for (int pageNo = firstPage; pageNo <= lastPage; pageNo++) { snprintf (pathName, sizeof (pathName) - 1, destFileName, pageNo); GooString *gpageName = new GooString (pathName); - int errCode = doc->savePageAs(gpageName, pageNo); + PDFDoc *pagedoc = new PDFDoc (new GooString (srcFileName), NULL, NULL, NULL); + int errCode = pagedoc->savePageAs(gpageName, pageNo); if ( errCode != errNone) { delete gpageName; delete doc; + delete pagedoc; return false; } + delete pagedoc; delete gpageName; } delete doc;