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

Modules/getpath.c

index f28f4c6ddff75cf9b95bb121b18a572d0fe3e035..9faafa3555dcdf67dc49be5935f8e5866829760d 100644 (file)
@@ -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);