mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-22 22:58:33 +00:00
flatten scalar references for unreferenced objects
git-svn-id: svn+q:///qpdf/trunk@946 71b93d88-0707-0410-a8cf-f5a4172ac649
This commit is contained in:
parent
028f106bee
commit
218900d2c3
@ -69,18 +69,25 @@ QPDF::flattenScalarReferences()
|
||||
queue.push_back(this->trailer);
|
||||
std::set<ObjGen> visited;
|
||||
|
||||
// Add every object in the xref table to the queue. This ensures
|
||||
// that we flatten scalar references in unreferenced objects.
|
||||
// This becomes important if we are preserving object streams in a
|
||||
// file that has unreferenced objects in its object streams. (See
|
||||
// QPDF bug 2974522 at SourceForge.)
|
||||
for (std::map<ObjGen, QPDFXRefEntry>::iterator iter =
|
||||
this->xref_table.begin();
|
||||
iter != this->xref_table.end(); ++iter)
|
||||
{
|
||||
ObjGen const& og = (*iter).first;
|
||||
queue.push_back(getObjectByID(og.obj, og.gen));
|
||||
}
|
||||
|
||||
while (! queue.empty())
|
||||
{
|
||||
QPDFObjectHandle node = queue.front();
|
||||
queue.pop_front();
|
||||
if (node.isIndirect())
|
||||
{
|
||||
if (node.isScalar())
|
||||
{
|
||||
throw std::logic_error(
|
||||
"INTERNAL ERROR:"
|
||||
" flattenScalarReferences landed at indirect scalar");
|
||||
}
|
||||
ObjGen og(node.getObjectID(), node.getGeneration());
|
||||
if (visited.count(og) > 0)
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ flush_tiff_cache();
|
||||
show_ntests();
|
||||
# ----------
|
||||
$td->notify("--- Miscellaneous Tests ---");
|
||||
$n_tests += 16;
|
||||
$n_tests += 18;
|
||||
|
||||
$td->runtest("qpdf version",
|
||||
{$td->COMMAND => "qpdf --version"},
|
||||
@ -121,6 +121,19 @@ $td->runtest("show new xref stream",
|
||||
$td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
|
||||
# Handle file with object stream containing an unreferenced object
|
||||
# that in turn contains an indirect scalar (bug 2974522).
|
||||
$td->runtest("unreferenced indirect scalar",
|
||||
{$td->COMMAND =>
|
||||
"qpdf --qdf --static-id --object-streams=preserve" .
|
||||
" unreferenced-indirect-scalar.pdf a.qdf"},
|
||||
{$td->STRING => "",
|
||||
$td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("check output",
|
||||
{$td->FILE => "a.qdf"},
|
||||
{$td->FILE => "unreferenced-indirect-scalar.out"});
|
||||
|
||||
# Min/Force version
|
||||
$td->runtest("set min version",
|
||||
{$td->COMMAND => "qpdf --min-version=1.6 good1.pdf a.pdf"},
|
||||
|
BIN
qpdf/qtest/qpdf/unreferenced-indirect-scalar.out
Normal file
BIN
qpdf/qtest/qpdf/unreferenced-indirect-scalar.out
Normal file
Binary file not shown.
BIN
qpdf/qtest/qpdf/unreferenced-indirect-scalar.pdf
Normal file
BIN
qpdf/qtest/qpdf/unreferenced-indirect-scalar.pdf
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user