Commit ddad5ad53ec8b9a0555beee84c92e1ec4cc1766f
1 parent
0dee3970
In QPDF::pipeStreamData use unique_ptr as heap
Showing
3 changed files
with
10 additions
and
10 deletions
include/qpdf/QPDF.hh
| ... | ... | @@ -1133,7 +1133,7 @@ class QPDF |
| 1133 | 1133 | Pipeline*& pipeline, |
| 1134 | 1134 | QPDFObjGen const& og, |
| 1135 | 1135 | QPDFObjectHandle& stream_dict, |
| 1136 | - std::vector<std::shared_ptr<Pipeline>>& heap); | |
| 1136 | + std::unique_ptr<Pipeline>& heap); | |
| 1137 | 1137 | |
| 1138 | 1138 | // Methods to support object copying |
| 1139 | 1139 | void reserveObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top); | ... | ... |
libqpdf/QPDF.cc
| ... | ... | @@ -2413,7 +2413,7 @@ QPDF::pipeStreamData( |
| 2413 | 2413 | bool suppress_warnings, |
| 2414 | 2414 | bool will_retry) |
| 2415 | 2415 | { |
| 2416 | - std::vector<std::shared_ptr<Pipeline>> to_delete; | |
| 2416 | + std::unique_ptr<Pipeline> to_delete; | |
| 2417 | 2417 | if (encp->encrypted) { |
| 2418 | 2418 | decryptStream(encp, file, qpdf_for_warning, pipeline, og, stream_dict, to_delete); |
| 2419 | 2419 | } | ... | ... |
libqpdf/QPDF_encryption.cc
| ... | ... | @@ -1038,6 +1038,9 @@ QPDF::decryptString(std::string& str, QPDFObjGen const& og) |
| 1038 | 1038 | } |
| 1039 | 1039 | } |
| 1040 | 1040 | |
| 1041 | +// Prepend a decryption pipeline to 'pipeline'. The decryption pipeline (returned as | |
| 1042 | +// 'decrypt_pipeline' must be owned by the caller to ensure that it stays alive while the pipeline | |
| 1043 | +// is in use. | |
| 1041 | 1044 | void |
| 1042 | 1045 | QPDF::decryptStream( |
| 1043 | 1046 | std::shared_ptr<EncryptionParameters> encp, |
| ... | ... | @@ -1046,7 +1049,7 @@ QPDF::decryptStream( |
| 1046 | 1049 | Pipeline*& pipeline, |
| 1047 | 1050 | QPDFObjGen const& og, |
| 1048 | 1051 | QPDFObjectHandle& stream_dict, |
| 1049 | - std::vector<std::shared_ptr<Pipeline>>& heap) | |
| 1052 | + std::unique_ptr<Pipeline>& decrypt_pipeline) | |
| 1050 | 1053 | { |
| 1051 | 1054 | std::string type; |
| 1052 | 1055 | if (stream_dict.getKey("/Type").isName()) { |
| ... | ... | @@ -1082,8 +1085,7 @@ QPDF::decryptStream( |
| 1082 | 1085 | crypt_params.getKey("/Name").isName()) { |
| 1083 | 1086 | QTC::TC("qpdf", "QPDF_encrypt crypt array"); |
| 1084 | 1087 | method = interpretCF(encp, crypt_params.getKey("/Name")); |
| 1085 | - method_source = "stream's Crypt " | |
| 1086 | - "decode parameters (array)"; | |
| 1088 | + method_source = "stream's Crypt decode parameters (array)"; | |
| 1087 | 1089 | } |
| 1088 | 1090 | } |
| 1089 | 1091 | } |
| ... | ... | @@ -1132,10 +1134,9 @@ QPDF::decryptStream( |
| 1132 | 1134 | } |
| 1133 | 1135 | } |
| 1134 | 1136 | std::string key = getKeyForObject(encp, og, use_aes); |
| 1135 | - std::shared_ptr<Pipeline> new_pipeline; | |
| 1136 | 1137 | if (use_aes) { |
| 1137 | 1138 | QTC::TC("qpdf", "QPDF_encryption aes decode stream"); |
| 1138 | - new_pipeline = std::make_shared<Pl_AES_PDF>( | |
| 1139 | + decrypt_pipeline = std::make_unique<Pl_AES_PDF>( | |
| 1139 | 1140 | "AES stream decryption", |
| 1140 | 1141 | pipeline, |
| 1141 | 1142 | false, |
| ... | ... | @@ -1143,14 +1144,13 @@ QPDF::decryptStream( |
| 1143 | 1144 | key.length()); |
| 1144 | 1145 | } else { |
| 1145 | 1146 | QTC::TC("qpdf", "QPDF_encryption rc4 decode stream"); |
| 1146 | - new_pipeline = std::make_shared<Pl_RC4>( | |
| 1147 | + decrypt_pipeline = std::make_unique<Pl_RC4>( | |
| 1147 | 1148 | "RC4 stream decryption", |
| 1148 | 1149 | pipeline, |
| 1149 | 1150 | QUtil::unsigned_char_pointer(key), |
| 1150 | 1151 | toI(key.length())); |
| 1151 | 1152 | } |
| 1152 | - pipeline = new_pipeline.get(); | |
| 1153 | - heap.push_back(new_pipeline); | |
| 1153 | + pipeline = decrypt_pipeline.get(); | |
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | 1156 | void | ... | ... |