diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-07 23:37:08 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-10-07 23:37:08 (GMT) |
commit | 354fe7e38148741d93ad2184b5c232b142bf6ac8 (patch) | |
tree | d455103fc3b3a6e2c4f7a8615de9591ea89dd545 | |
parent | a06e9b8f6b2edf4936146fa8867f12222106d0f8 (diff) | |
download | cpython-354fe7e38148741d93ad2184b5c232b142bf6ac8.zip cpython-354fe7e38148741d93ad2184b5c232b142bf6ac8.tar.gz cpython-354fe7e38148741d93ad2184b5c232b142bf6ac8.tar.bz2 |
copy_absolute(): keep the relative path if getcwd() failed
Instead of using the undefined content of the 'path' buffer.
-rw-r--r-- | Modules/getpath.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c index f28f4c6..9faafa3 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); |