aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFPageDocumentHelper.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-01-03 14:17:59 +0100
committerJay Berkenbilt <ejb@ql.org>2019-01-03 15:17:43 +0100
commit06d6438ddf7f817d9cc1698c9b4b5e4b8f53e151 (patch)
tree9c35acc473865e3a988848c4fd1e5cf4e8b67715 /libqpdf/QPDFPageDocumentHelper.cc
parent3e74916c5a658d310c37b7dd73b0305c0d1e8ff9 (diff)
downloadqpdf-06d6438ddf7f817d9cc1698c9b4b5e4b8f53e151.tar.zst
Minor fixes
Diffstat (limited to 'libqpdf/QPDFPageDocumentHelper.cc')
-rw-r--r--libqpdf/QPDFPageDocumentHelper.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/libqpdf/QPDFPageDocumentHelper.cc b/libqpdf/QPDFPageDocumentHelper.cc
index 7b171e9a..d168f8de 100644
--- a/libqpdf/QPDFPageDocumentHelper.cc
+++ b/libqpdf/QPDFPageDocumentHelper.cc
@@ -164,7 +164,8 @@ QPDFPageDocumentHelper::flattenAnnotationsForPage(
}
std::set<std::string> names = resources.getResourceNames();
std::string name;
- while (next_fx < 1000000)
+ int max_fx = next_fx + names.size() + 1;
+ while (next_fx <= max_fx)
{
std::string candidate = "/Fxo" + QUtil::int_to_string(next_fx);
++next_fx;
@@ -176,9 +177,9 @@ QPDFPageDocumentHelper::flattenAnnotationsForPage(
}
if (name.empty())
{
- // There are already more than a million /Fxo names.
- // Somehow I doubt this is going to actually happen.
- // Just pick a name and forget conflicts.
+ // This could only happen if there is a coding error.
+ // The number of candidates we test is more than the
+ // number of keys we're checking against.
name = "/FxConflict";
}
resources.mergeResources(