mirror of
https://github.com/qpdf/qpdf.git
synced 2025-02-02 11:58:25 +00:00
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.
This commit is contained in:
parent
60ec94a7c3
commit
051ae7c282
@ -1468,7 +1468,9 @@ QPDFObjectHandle::replaceStreamData(
|
|||||||
assertStream();
|
assertStream();
|
||||||
auto b = std::make_shared<Buffer>(data.length());
|
auto b = std::make_shared<Buffer>(data.length());
|
||||||
unsigned char* bp = b->getBuffer();
|
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(
|
dynamic_cast<QPDF_Stream*>(obj.get())->replaceStreamData(
|
||||||
b, filter, decode_parms);
|
b, filter, decode_parms);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user