Skip to content

Commit

Permalink
BUG: Avoid IndexError in _cmap.parse_to_unicode (py-pdf#1110)
Browse files Browse the repository at this point in the history
The code within the if block assumes that `lst` has index 0 and index 1.

Fixes py-pdf#1091
Related to py-pdf#1111
  • Loading branch information
dkg authored Jul 14, 2022
1 parent 5e1cc57 commit bb2d1db
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion PyPDF2/_cmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def parse_to_unicode(
elif process_char:
lst = [x for x in l.split(b" ") if x]
map_dict[-1] = len(lst[0]) // 2
while len(lst) > 0:
while len(lst) > 1:
map_dict[
unhexlify(lst[0]).decode(
"charmap" if map_dict[-1] == 1 else "utf-16-be", "surrogatepass"
Expand Down

0 comments on commit bb2d1db

Please sign in to comment.