aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2023-11-18 15:40:32 +0100
committerm-holger <m-holger@kubitscheck.org>2023-11-26 14:06:12 +0100
commitddad5ad53ec8b9a0555beee84c92e1ec4cc1766f (patch)
tree16c5650d6aaa0d5c06293ec6fe0a7055a08a86ce /libqpdf
parent0dee39707583b300bc745c923452a848d0f02c88 (diff)
downloadqpdf-ddad5ad53ec8b9a0555beee84c92e1ec4cc1766f.tar.zst
In QPDF::pipeStreamData use unique_ptr as heap
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDF.cc2
-rw-r--r--libqpdf/QPDF_encryption.cc16
2 files changed, 9 insertions, 9 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index 01f1f339..f6badc35 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -2413,7 +2413,7 @@ QPDF::pipeStreamData(
bool suppress_warnings,
bool will_retry)
{
- std::vector<std::shared_ptr<Pipeline>> to_delete;
+ std::unique_ptr<Pipeline> to_delete;
if (encp->encrypted) {
decryptStream(encp, file, qpdf_for_warning, pipeline, og, stream_dict, to_delete);
}
diff --git a/libqpdf/QPDF_encryption.cc b/libqpdf/QPDF_encryption.cc
index d405b4dd..1dd7b963 100644
--- a/libqpdf/QPDF_encryption.cc
+++ b/libqpdf/QPDF_encryption.cc
@@ -1038,6 +1038,9 @@ QPDF::decryptString(std::string& str, QPDFObjGen const& og)
}
}
+// Prepend a decryption pipeline to 'pipeline'. The decryption pipeline (returned as
+// 'decrypt_pipeline' must be owned by the caller to ensure that it stays alive while the pipeline
+// is in use.
void
QPDF::decryptStream(
std::shared_ptr<EncryptionParameters> encp,
@@ -1046,7 +1049,7 @@ QPDF::decryptStream(
Pipeline*& pipeline,
QPDFObjGen const& og,
QPDFObjectHandle& stream_dict,
- std::vector<std::shared_ptr<Pipeline>>& heap)
+ std::unique_ptr<Pipeline>& decrypt_pipeline)
{
std::string type;
if (stream_dict.getKey("/Type").isName()) {
@@ -1082,8 +1085,7 @@ QPDF::decryptStream(
crypt_params.getKey("/Name").isName()) {
QTC::TC("qpdf", "QPDF_encrypt crypt array");
method = interpretCF(encp, crypt_params.getKey("/Name"));
- method_source = "stream's Crypt "
- "decode parameters (array)";
+ method_source = "stream's Crypt decode parameters (array)";
}
}
}
@@ -1132,10 +1134,9 @@ QPDF::decryptStream(
}
}
std::string key = getKeyForObject(encp, og, use_aes);
- std::shared_ptr<Pipeline> new_pipeline;
if (use_aes) {
QTC::TC("qpdf", "QPDF_encryption aes decode stream");
- new_pipeline = std::make_shared<Pl_AES_PDF>(
+ decrypt_pipeline = std::make_unique<Pl_AES_PDF>(
"AES stream decryption",
pipeline,
false,
@@ -1143,14 +1144,13 @@ QPDF::decryptStream(
key.length());
} else {
QTC::TC("qpdf", "QPDF_encryption rc4 decode stream");
- new_pipeline = std::make_shared<Pl_RC4>(
+ decrypt_pipeline = std::make_unique<Pl_RC4>(
"RC4 stream decryption",
pipeline,
QUtil::unsigned_char_pointer(key),
toI(key.length()));
}
- pipeline = new_pipeline.get();
- heap.push_back(new_pipeline);
+ pipeline = decrypt_pipeline.get();
}
void