diff options
author | Jay Berkenbilt <ejb@ql.org> | 2017-08-12 13:35:04 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2017-08-12 14:36:36 +0200 |
commit | 8249a26d69f72b9cda584c14cc3f12769985e481 (patch) | |
tree | 75efa7eeb1899f081e78a10d0bb306d2dfb04531 /libqpdf/QPDFWriter.cc | |
parent | 36b3fe5af761b7032a506808cf6ce6d37c297bfc (diff) | |
download | qpdf-8249a26d69f72b9cda584c14cc3f12769985e481.tar.zst |
Fix infinite loop in QPDFWriter (fixes #143)
Diffstat (limited to 'libqpdf/QPDFWriter.cc')
-rw-r--r-- | libqpdf/QPDFWriter.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index de4fa349..345613ad 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -1054,6 +1054,9 @@ QPDFWriter::enqueueObject(QPDFObjectHandle object) // here. Instead, enqueue the object stream. Object // streams always have generation 0. int stream_id = this->object_to_object_stream[og]; + // Detect loops by storing invalid object ID 0, which + // will get overwritten later. + obj_renumber[og] = 0; enqueueObject(this->pdf.getObjectByID(stream_id, 0)); } else @@ -1079,6 +1082,12 @@ QPDFWriter::enqueueObject(QPDFObjectHandle object) } } } + else if (obj_renumber[og] == 0) + { + // This can happen if a specially constructed file + // indicates that an object stream is inside itself. + QTC::TC("qpdf", "QPDFWriter ignore self-referential object stream"); + } } else if (object.isArray()) { |