diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-05-16 17:07:26 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-05-16 19:39:26 +0200 |
commit | 051ae7c282b5487a0dfb5214b9855cd45066c813 (patch) | |
tree | 11b601cc6534d1337654283eedad078fa946aa23 | |
parent | 60ec94a7c35ff3f7153c99deff29afef91500622 (diff) | |
download | qpdf-051ae7c282b5487a0dfb5214b9855cd45066c813.tar.zst |
Improve handling of replacing stream data with empty strings
When an empty string was passed to replaceStreamData, the code was
passing a null pointer to memcpy. Since a 0 size was also passed, this
was harmless, but it triggers sanitizer errors. The code properly
handles a null pointer as the buffer in other places.
-rw-r--r-- | libqpdf/QPDFObjectHandle.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index 10fb153c..4a61f595 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -1468,7 +1468,9 @@ QPDFObjectHandle::replaceStreamData( assertStream(); auto b = std::make_shared<Buffer>(data.length()); unsigned char* bp = b->getBuffer(); - memcpy(bp, data.c_str(), data.length()); + if (bp) { + memcpy(bp, data.c_str(), data.length()); + } dynamic_cast<QPDF_Stream*>(obj.get())->replaceStreamData( b, filter, decode_parms); } |