OSDN Git Service

Fix mac build of bit
authorJoe Onorato <joeo@google.com>
Fri, 21 Oct 2016 21:31:42 +0000 (14:31 -0700)
committerJoe Onorato <joeo@google.com>
Fri, 21 Oct 2016 21:32:01 +0000 (14:32 -0700)
Test: make bit
Change-Id: I8005e77babfbe2d48806f9315800e699d1917bb4

tools/bit/main.cpp

index 04836ad..4974a44 100644 (file)
@@ -518,14 +518,17 @@ get_out_dir()
             // makes all the filenames long when being pretty printed.
             return "out";
         } else {
-            char* pwd = get_current_dir_name();
+            char pwd[PATH_MAX];
+            if (getcwd(pwd, PATH_MAX) == NULL) {
+                fprintf(stderr, "Your pwd is too long.\n");
+                exit(1);
+            }
             const char* slash = strrchr(pwd, '/');
             if (slash == NULL) {
                 slash = "";
             }
             string result(common_base);
             result += slash;
-            free(pwd);
             return result;
         }
     }