LibPDF: Fix two use-after-frees

Two lambdas were capturing locals that were out of scope by the
time the lambdas ran.

With this, `pdf` can successfully load and print the page count of
pdf_reference_1.7.pdf.
This commit is contained in:
Nico Weber 2023-07-10 11:21:16 -04:00 committed by Sam Atkins
parent 6111a9f9d0
commit 826c0426f3
Notes: sideshowbarker 2024-07-17 01:10:58 +09:00

View file

@ -323,8 +323,8 @@ void StandardSecurityHandler::encrypt(NonnullRefPtr<Object> object, Reference re
auto stream = object->cast<StreamObject>();
bytes = stream->bytes();
assign = [&stream](ByteBuffer const& buffer) {
stream->buffer() = buffer;
assign = [&object](ByteBuffer const& buffer) {
object->cast<StreamObject>()->buffer() = buffer;
};
if (stream->dict()->contains(CommonNames::Filter)) {
@ -335,8 +335,8 @@ void StandardSecurityHandler::encrypt(NonnullRefPtr<Object> object, Reference re
} else if (object->is<StringObject>()) {
auto string = object->cast<StringObject>();
bytes = string->string().bytes();
assign = [&string](ByteBuffer const& buffer) {
string->set_string(DeprecatedString(buffer.bytes()));
assign = [&object](ByteBuffer const& buffer) {
object->cast<StringObject>()->set_string(DeprecatedString(buffer.bytes()));
};
} else {
VERIFY_NOT_REACHED();