]> rtime.felk.cvut.cz Git - git.git/blobdiff - path.c
expand_user_path: do not look at NULL path
[git.git] / path.c
diff --git a/path.c b/path.c
index 6f2aa699ad63c2f7c65632761efbaebb7f461868..3a5796156bd3d59fbf7627ca4292f60bd5d79b01 100644 (file)
--- a/path.c
+++ b/path.c
@@ -231,12 +231,12 @@ static struct passwd *getpw_str(const char *username, size_t len)
 char *expand_user_path(const char *path)
 {
        struct strbuf user_path = STRBUF_INIT;
-       const char *first_slash = strchrnul(path, '/');
        const char *to_copy = path;
 
        if (path == NULL)
                goto return_null;
        if (path[0] == '~') {
+               const char *first_slash = strchrnul(path, '/');
                const char *username = path + 1;
                size_t username_len = first_slash - username;
                if (username_len == 0) {