Skip to content

Commit

Permalink
🐛 Handle .decode possibly applied to None
Browse files Browse the repository at this point in the history
  • Loading branch information
unode committed Jul 6, 2023
1 parent 914fc85 commit 2c61b27
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion firefox_decrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,10 @@ def _set_ctypes(self, restype, name, *argtypes):
# Transparently handle decoding to string when returning a c_char_p
if restype == ct.c_char_p:
def _decode(result, func, *args):
return result.decode(DEFAULT_ENCODING)
try:
return result.decode(DEFAULT_ENCODING)
except AttributeError:
return result
res.errcheck = _decode

setattr(self, "_" + name, res)
Expand Down

0 comments on commit 2c61b27

Please sign in to comment.