aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF_encryption.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2011-08-11 17:56:37 +0200
committerJay Berkenbilt <ejb@ql.org>2011-08-11 17:57:37 +0200
commit76b1659177327a64037bf36d7f3e15a73d86bbed (patch)
tree22623001bb99a6fe33943416877a3d5836b550d8 /libqpdf/QPDF_encryption.cc
parent14fe2e6de3ae3b91436ccb4948fca75c29565440 (diff)
downloadqpdf-76b1659177327a64037bf36d7f3e15a73d86bbed.tar.zst
enhance PointerHolder so that it can explicitly be told to use delete [] instead of delete, thus making it useful to run valgrind over qpdf during its test suite
Diffstat (limited to 'libqpdf/QPDF_encryption.cc')
-rw-r--r--libqpdf/QPDF_encryption.cc7
1 files changed, 2 insertions, 5 deletions
diff --git a/libqpdf/QPDF_encryption.cc b/libqpdf/QPDF_encryption.cc
index d559388b..772d87e0 100644
--- a/libqpdf/QPDF_encryption.cc
+++ b/libqpdf/QPDF_encryption.cc
@@ -589,12 +589,9 @@ QPDF::decryptString(std::string& str, int objid, int generation)
{
QTC::TC("qpdf", "QPDF_encryption rc4 decode string");
unsigned int vlen = str.length();
- // Using PointerHolder will cause a new char[] to be deleted
- // with delete instead of delete [], but it's okay since the
- // array is of a fundamental type, so there is no destructor
- // to be called. Using PointerHolder guarantees that tmp will
+ // Using PointerHolder guarantees that tmp will
// be freed even if rc4.process throws an exception.
- PointerHolder<char> tmp = QUtil::copy_string(str);
+ PointerHolder<char> tmp(true, QUtil::copy_string(str));
RC4 rc4((unsigned char const*)key.c_str(), key.length());
rc4.process((unsigned char*)tmp.getPointer(), vlen);
str = std::string(tmp.getPointer(), vlen);