From: Victor Stinner Date: Thu, 7 Oct 2010 23:37:08 +0000 (+0000) Subject: copy_absolute(): keep the relative path if getcwd() failed X-Git-Tag: v2.7.1rc1~190 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=354fe7e38148741d93ad2184b5c232b142bf6ac8;p=python copy_absolute(): keep the relative path if getcwd() failed Instead of using the undefined content of the 'path' buffer. --- diff --git a/Modules/getpath.c b/Modules/getpath.c index f28f4c6ddf..9faafa3555 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -232,7 +232,11 @@ copy_absolute(char *path, char *p) if (p[0] == SEP) strcpy(path, p); else { - getcwd(path, MAXPATHLEN); + if (!getcwd(path, MAXPATHLEN)) { + /* unable to get the current directory */ + strcpy(path, p); + return; + } if (p[0] == '.' && p[1] == SEP) p += 2; joinpath(path, p);