]> granicus.if.org Git - python/commitdiff
copy_absolute(): keep the relative path if _wgetcwd() failed
authorVictor Stinner <victor.stinner@haypocalc.com>
Thu, 7 Oct 2010 23:39:04 +0000 (23:39 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Thu, 7 Oct 2010 23:39:04 +0000 (23:39 +0000)
Instead of using the undefined content of the 'path' buffer.

Modules/getpath.c

index 9c59ef1cf81d01a32819cf1325bf0c74ce0ef581..112d6d38e6f21a38ce6749a66b45d6da463ee839 100644 (file)
@@ -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);