From a07f411548e6f3c87d59c4a2e4a292115ed5d962 Mon Sep 17 00:00:00 2001 From: Josip Date: Sun, 6 Apr 2014 00:14:33 +0200 Subject: [PATCH] Change use of GetEnvironmentVariableW (#7582) --- gramps/gen/constfunc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gramps/gen/constfunc.py b/gramps/gen/constfunc.py index 4c2270304..a8185383e 100644 --- a/gramps/gen/constfunc.py +++ b/gramps/gen/constfunc.py @@ -184,7 +184,8 @@ def get_env_var(name, default=None): n = ctypes.windll.kernel32.GetEnvironmentVariableW(name, None, 0) if n==0: return default - buf = ctypes.create_unicode_buffer(u'\0'*n) + # n is number of codepoints + buf = ctypes.create_unicode_buffer(n+1) ctypes.windll.kernel32.GetEnvironmentVariableW(name, buf, n) return buf.value