aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--libqpdf/QPDFPageDocumentHelper.cc9
2 files changed, 11 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index ec5d9ec8..18dc216c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-01-02 Jay Berkenbilt <ejb@ql.org>
+
+ * Add method QPDFObjectHandle::getResourceNames that returns a set
+ of strings representing all second-level keys in a dictionary
+ (i.e. all keys of all direct dictionary members).
+
2018-12-31 Jay Berkenbilt <ejb@ql.org>
* Add methods for flattening form fields and annotations:
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(