Skip to content

Commit

Permalink
Ensure indirect sweep to handle all objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry Karvonen committed Jul 5, 2022
1 parent a345690 commit 190479c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions PyPDF2/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,19 @@ def _sweep_indirect_references(
extern_map[data.pdf][data.generation] = {}
extern_map[data.pdf][data.generation][data.idnum] = newobj_ido
newobj = self._sweep_indirect_references(extern_map, newobj)
# Ensure that all objects is handled
hash_value = None
if newobj is not None:
hash_value = newobj.hash_value()
# Check if object is already added to pdf.
if hash_value in self._idnum_hash:
newobj_ido = IndirectObject(
self._idnum_hash[hash_value], 0, self
)
self._objects[idnum - 1] = newobj_ido
return newobj_ido
if hash_value is not None:
self._idnum_hash[hash_value] = idnum
self._objects[idnum - 1] = newobj
return newobj_ido
except (ValueError, RecursionError):
Expand Down

0 comments on commit 190479c

Please sign in to comment.