diff --git a/pywinauto/handleprops.py b/pywinauto/handleprops.py index b0d43a2..79ffb36 100644 --- a/pywinauto/handleprops.py +++ b/pywinauto/handleprops.py @@ -52,7 +52,9 @@ def text(handle): length = length.value textval = '' - if length: + # In some rare cases, the length returned by WM_GETTEXTLENGTH is <0. + # Guard against this by checking it is >0 (==0 is not of interest): + if length > 0: length += 1 buffer_ = ctypes.create_unicode_buffer(length)