aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFParser.cc
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-12-19 12:41:09 +0100
committerJay Berkenbilt <jberkenbilt@users.noreply.github.com>2022-12-31 20:37:35 +0100
commit9da50ca3601ee58c2ccceaa5d430b56a1ab27306 (patch)
tree7518877907dfd1c2e43cad161b04b6fcdac272b5 /libqpdf/QPDFParser.cc
parente91e642cf35a704866f1dabd89d9a987a309bcc2 (diff)
downloadqpdf-9da50ca3601ee58c2ccceaa5d430b56a1ab27306.tar.zst
Change olist variable in QPDFParser::parse to vector<shared_ptr<QPDFObject>>
Diffstat (limited to 'libqpdf/QPDFParser.cc')
-rw-r--r--libqpdf/QPDFParser.cc27
1 files changed, 14 insertions, 13 deletions
diff --git a/libqpdf/QPDFParser.cc b/libqpdf/QPDFParser.cc
index d190835d..6b3cdb4e 100644
--- a/libqpdf/QPDFParser.cc
+++ b/libqpdf/QPDFParser.cc
@@ -33,7 +33,7 @@ namespace
{
}
- std::vector<QPDFObjectHandle> olist;
+ std::vector<std::shared_ptr<QPDFObject>> olist;
qpdf_offset_t offset;
std::string contents_string;
qpdf_offset_t contents_offset;
@@ -67,7 +67,7 @@ QPDFParser::parse(bool& empty, bool content_stream)
int good_count = 0;
bool b_contents = false;
bool is_null = false;
- auto null_oh = QPDFObjectHandle::newNull();
+ auto null_oh = QPDF_Null::create();
while (!done) {
bool bad = false;
@@ -191,11 +191,13 @@ QPDFParser::parse(bool& empty, bool content_stream)
if (content_stream) {
object = QPDF_Operator::create(value);
} else if (
- (value == "R") && (state != st_top) && (size >= 2) &&
- (!olist.back().isIndirect()) &&
- (olist.back().isInteger()) &&
- (!olist.at(size - 2).isIndirect()) &&
- (olist.at(size - 2).isInteger())) {
+ value == "R" && state != st_top && size >= 2 &&
+ olist.back() &&
+ olist.back()->getTypeCode() == ::ot_integer &&
+ !olist.back()->getObjGen().isIndirect() &&
+ olist.at(size - 2) &&
+ olist.at(size - 2)->getTypeCode() == ::ot_integer &&
+ !olist.at(size - 2)->getObjGen().isIndirect()) {
if (context == nullptr) {
QTC::TC("qpdf", "QPDFParser indirect without context");
throw std::logic_error(
@@ -203,8 +205,8 @@ QPDFParser::parse(bool& empty, bool content_stream)
" on an object with indirect references");
}
auto ref_og = QPDFObjGen(
- olist.at(size - 2).getIntValueAsInt(),
- olist.back().getIntValueAsInt());
+ QPDFObjectHandle(olist.at(size - 2)).getIntValueAsInt(),
+ QPDFObjectHandle(olist.back()).getIntValueAsInt());
if (ref_og.isIndirect()) {
// This action has the desirable side effect
// of causing dangling references (references
@@ -306,7 +308,7 @@ QPDFParser::parse(bool& empty, bool content_stream)
setDescription(object, input->getLastOffset());
}
set_offset = true;
- olist.push_back(is_null ? null_oh : QPDFObjectHandle(object));
+ olist.push_back(is_null ? null_oh : object);
break;
case st_top:
@@ -325,7 +327,7 @@ QPDFParser::parse(bool& empty, bool content_stream)
parser_state_e old_state = state_stack.back();
state_stack.pop_back();
if (old_state == st_array) {
- object = QPDF_Array::create(olist);
+ object = QPDF_Array::create(std::move(olist));
setDescription(object, offset - 1);
// The `offset` points to the next of "[". Set the rewind
// offset to point to the beginning of "[". This has been
@@ -412,8 +414,7 @@ QPDFParser::parse(bool& empty, bool content_stream)
if (state_stack.back() == st_top) {
done = true;
} else {
- stack.back().olist.push_back(
- is_null ? null_oh : QPDFObjectHandle(object));
+ stack.back().olist.push_back(is_null ? null_oh : object);
}
}
}