From: Victor Stinner Date: Thu, 7 Oct 2010 23:39:04 +0000 (+0000) Subject: copy_absolute(): keep the relative path if _wgetcwd() failed X-Git-Tag: v3.1.3rc1~140 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=08538bc579a4b91f63bb809b37cc2c353daa451f;p=thirdparty%2FPython%2Fcpython.git copy_absolute(): keep the relative path if _wgetcwd() failed Instead of using the undefined content of the 'path' buffer. --- diff --git a/Modules/getpath.c b/Modules/getpath.c index 9c59ef1cf81d..112d6d38e6f2 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -300,7 +300,11 @@ copy_absolute(wchar_t *path, wchar_t *p) if (p[0] == SEP) wcscpy(path, p); else { - _wgetcwd(path, MAXPATHLEN); + if (!_wgetcwd(path, MAXPATHLEN)) { + /* unable to get the current directory */ + wcscpy(path, p); + return; + } if (p[0] == '.' && p[1] == SEP) p += 2; joinpath(path, p);